Reputation: 2942
In the oh-my-zsh's upgrade tool, I found this line(line 2):
current_path=${current_path/ /\\ }
What it did?
Additionally, this line works on mac, but on my ubuntu server it output a error says:
.oh-my-zsh/tools/upgrade.sh: 2: .oh-my-zsh/tools/upgrade.sh: Bad substitution
Upvotes: 2
Views: 2325
Reputation: 3837
I managed to update using commands:
cd ~/.oh-my-zsh
ggpull
#or
git pull origin master
Upvotes: 1
Reputation: 4109
Updated it on Ubuntu with
cd ~/.oh-my-zsh
bash ~/.oh-my-zsh/tools/upgrade.sh
Upvotes: 11
Reputation: 45686
See parameter expansion in the manual.
${name/pattern/repl} ${name//pattern/repl} Replace the longest possible match of pattern in the expansion of parameter name by string repl. The first form replaces just the first occurrence, the second form all occurrences.
In essence, what the above does is prepend a backslash to the first space in ${current_path}
.
Note that this syntax is not specified by POSIX (see here for more info), but all current bash
, ksh
and zsh
versions support it. The Bad substitution
error suggests that you are not running the upgrade.sh
tool under the shell that you think you do (one which does not support it).
Upvotes: 2
Reputation: 19495
That line will backslash escape the first space in the $current_path
variable. That type of substitution isn't supported by all shells, which is why it fails on Ubuntu.
As far as I can tell, there is no good reason for that line to be there. If escaping white space where necessary, that method would be insufficient even if it worked. Worse, since the only later use of the variable has it in double quotes having backslash escapes for spaces actually breaks it.
Upvotes: 1