I’ve been writing a little bash script to wrap up the functionality in the JIRA CLI, and i’d noticed that sometimes, my script was spitting out the following error:
sh.exe": [: too many arguments
The code in question was:
j () {
if [ -z $3 ]; then
echo jira --action progressIssue --issue "$1" --step "$2";
...
...
It turns out the problem was that the variable $3 in the second line was being substituted directly into the if statement, without being quote delimited. So Bash is treating any input in $3 with spaces as multiple arguments (hence the "too many arguments" error). Duh.
Solution is to quote the $3 variable in the conditional to treat it as a single argument. Shouldn't make this mistake again...
Related posts:
- e Text Editor: “ruby: no such file to load — ubygems (LoadError)” i’ve installed e text editor on my desktop and trying...
- Mounting NAS drive under Ubuntu I’ve been battling this one for a long time….Finally got...
- Making Resolving Conflicts in Git Easier One thing that bugs me when using Git, is that...
- Instant Twitter Bookmark Tonight’s been a busy night for silly coding This first...
- Scripting Google Chrome for OSX using AppleScript When it comes to software tools, i like to spend...