Add parameter to local/remote shell runner to change delimiter in named parameters
See original GitHub issueWhile assisting some users today, I ran into a problem with optparse
. In a nutshell, parsing options is hard in Bash, so there are many tendencies to shortcut. One such example:
while [ -n "$1" ]; do
case $1 in
-C|--gecos) gecos=$2; shift 2;;
-e|--email) email=$2; shift 2;;
-u|--userid) userid=$2; shift 2;;
-d|--dry-run) dryrun=1; shift;;
-h|--help) usage;;
*) shift;;
esac
done
Today, I can change the kwargs_op
to any prefix I so desire. But, in all cases, the input is distilled to a dict
, and then rendered as key-value pairs. (e.g.: --email=james@fryman.io
). This causes a failure with the above logic.
This is not an uncommon pattern, and it would be good to be able to s/=/ /
in the above parameter.
Issue Analytics
- State:
- Created 8 years ago
- Comments:9 (7 by maintainers)
Top Results From Across the Web
bash - Passing named arguments to shell scripts
When using the variables, one can make sure that they have a default value set by using "${p_out:-"default value"}" for example. From 3.5.3...
Read more >Changing parameter delimiters - LoadRunner Professional
I need to change my parameter delimiters so I go to Tools -> Options -> Scripting -> Parameters. I change left delimiter to...
Read more >The Shell executor - GitLab Docs
The Shell executor is a simple executor that you use to execute builds locally on the machine where GitLab Runner is installed. It...
Read more >Spring Cloud Data Flow Reference Guide
OAuth Authentication using the Spring Cloud Data Flow Shell; 14.3.3. ... <name of application> , So for example to set Java options for...
Read more >Bash Boilerplate Generator - toolstud.io
bash boilerplate shell sh macos linux. ... An multi is a multiple values parameter (can only be last parameter). Parameter 1. flag, option,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@lakshmi-kannan @manasdk fwiw, I’m not immediately blocked. The “workaround” was to fix the underlying script.
I avoided using the
cmd
jinja pattern hack as I think it’s certainly an antipattern we need to watch carefully. It is supported (https://docs.stackstorm.com/runners.html?highlight=runner#runner-parameters). It is disjointed to have the ability to modify thekwargs_op
option, but not have one for the delimiter between keyword parameters. If anything, dropping to thecmd
and writing it out manually all but nullifies the need forkwargs_op
, since I could define it in thecmd
for that need as well.I have a simple bash script with named cli arguments that I am trying to use the
local-shell-script
with. I was able to change thekwarg_op
seperator, but the runner still uses the=
to separate k/v items.So alittle script like this below would be called from the command like like:
./script.sh -r foo -w /tmp -s server -c client
or./script.sh -r foo -w /tmp
I don’t want to use positional args, because they aren’t all required.But using the following meta parameters. It gets passed by Stackstorm as
./script.sh -r=foo -w=/tmp -s=server -c=client
So now my args are passed to my script by
getopts
as=value
and I have to use the${OPTARG//=/}
to strip it off.