diff options
| author | Teddy Wing | 2017-10-04 22:55:55 +0200 |
|---|---|---|
| committer | Teddy Wing | 2017-10-04 22:55:55 +0200 |
| commit | 357eb2484bf58ed202b072b94fff54d81fe0fb49 (patch) | |
| tree | 68d3b5c4add67ae6206d7a1224f8565d29c5f16d | |
| parent | d72c0c18af130dac31329bdafb08a8ea48b0a669 (diff) | |
| download | qcd-357eb2484bf58ed202b072b94fff54d81fe0fb49.tar.bz2 | |
qcd: Update slash-escapes in change command for Bash 4
I was getting this error when running `qcd`'s change command on a
machine using Bash 4.4.12:
$ sed -E "s/^shortcut .+$/shortcut ${p//\//\/}/" .config/qcd/database
sed: 1: "s/^shortcut .+$/shortcut ...": bad flag in substitute command: 'U'
The solution, as described here:
https://stackoverflow.com/questions/27787536/how-to-pass-a-variable-containing-slashes-to-sed/27788661#27788661
is to add an extra backslash to the parameter expansion. This appears to
work on both Bash 3 and 4 in my local manual tests.
| -rwxr-xr-x | qcd | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -60,7 +60,7 @@ function __qcd_change_shortcut () { path=$(__qcd_absolute_path "$path") # The `//\//\/` escapes slashes in the path so that `sed` doesn't complain - sed -i.bak -E "s/^${shortcut} .+$/${shortcut} ${path//\//\/}/" $QCD_DATABASE_FILE + sed -i.bak -E "s/^${shortcut} .+$/${shortcut} ${path//\//\\/}/" $QCD_DATABASE_FILE fi } |
