Timeline for Passing named arguments to shell scripts
Current License: CC BY-SA 4.0
24 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Oct 19, 2023 at 8:46 | comment | added | steven | support passing argument names with an optional -- prefix could use for ARGUMENT in "$@";do export $(echo $ARGUMENT | cut -f1 -d=|cut -d '-' -f 3)=${ARGUMENT:$(echo $ARGUMENT | cut -f1 -d=|wc -L)+1}; done | |
| Aug 11, 2023 at 4:51 | comment | added | JRichardsz | Interesting. I think the only way could be set some values at the beginning. Check this gist.github.com/jrichardsz/… | |
| Aug 10, 2023 at 19:13 | comment | added | JGleason | Can I use default values here? | |
| Jun 20, 2023 at 16:48 | comment | added | Braden Steffaniak | You can also support passing argument names with an optional -- prefix (e.g. --profile=test) if you add [[ $KEY == --* ]] && KEY=${KEY:2} right before the export "$KEY"="$VALUE" line. | |
| Mar 18, 2023 at 16:51 | comment | added | JRichardsz | Yes, you are right. This is for simple key-value params. I dont' tested but maybe you could escape it : STEPS="\\nABC" | |
| Mar 18, 2023 at 16:16 | comment | added | Farid | This is gonna fail if you pass new line literal. Example: bash args_shell_parser.sh STEPS="\nABC" Do you know a way to resolve this? | |
| Mar 2, 2023 at 8:43 | comment | added | Juergen Schulze | export "${KEY,,}"="$VALUE" - to make variable/parameter names not case sensitive | |
| S Jan 24, 2022 at 16:43 | history | suggested | Bohdan Shulha | CC BY-SA 4.0 | Addded forgotten double quotes |
| Jan 23, 2022 at 23:06 | review | Suggested edits | |||
| S Jan 24, 2022 at 16:43 | |||||
| Jan 23, 2022 at 21:28 | comment | added | JRichardsz | Thanks for your suggestion #BohdanShulha It had an error. I fixed: gist.github.com/jrichardsz/… | |
| S Jan 23, 2022 at 21:25 | history | edited | JRichardsz | CC BY-SA 4.0 | improve explanation |
| S Jan 23, 2022 at 21:25 | history | suggested | Bohdan Shulha | CC BY-SA 4.0 | Adds support for values with "=" sign inside |
| Jan 23, 2022 at 20:36 | review | Suggested edits | |||
| S Jan 23, 2022 at 21:25 | |||||
| Jan 6, 2022 at 15:27 | history | edited | JRichardsz | CC BY-SA 4.0 | improve of script |
| Apr 14, 2021 at 14:12 | comment | added | JRichardsz | several systems will have problems with a variable like that. An equivalent could be PROPERTIES_LIST=apim:true&whichvalue:345 | |
| Apr 12, 2021 at 13:43 | comment | added | PaulNUK | Unfortunately this breaks if the value has an equals in it like this MYVAR="PROPERTIES_LIST":"\"apim=true&whichvalue=345\"" | |
| Nov 4, 2020 at 10:32 | comment | added | Jerry Green | This is neat but assumes you have = delimiter between the key and the value. I.e. you can't pass a value with a space like so: -p 3000 or --port 3000 | |
| Dec 13, 2019 at 17:22 | comment | added | JRichardsz | mmm in my case it is instantaneous. | |
| Dec 13, 2019 at 14:01 | comment | added | Astronaut | This is a neat solution, but it seems to take a long time to parse, like 5 to 10 seconds on my PC, is this normal behavior? | |
| Apr 5, 2019 at 22:43 | history | edited | Rui F Ribeiro | CC BY-SA 4.0 | deleted 16 characters in body |
| Feb 24, 2019 at 12:24 | history | edited | JRichardsz | CC BY-SA 4.0 | added 13 characters in body |
| Mar 24, 2017 at 20:36 | history | edited | JRichardsz | CC BY-SA 3.0 | added 13 characters in body |
| Mar 24, 2017 at 17:17 | review | First posts | |||
| Mar 24, 2017 at 17:30 | |||||
| Mar 24, 2017 at 17:17 | history | answered | JRichardsz | CC BY-SA 3.0 |