From 357eb2484bf58ed202b072b94fff54d81fe0fb49 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Wed, 4 Oct 2017 22:55:55 +0200 Subject: 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. --- qcd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qcd b/qcd index 4cb18fa..091ba1a 100755 --- a/qcd +++ b/qcd @@ -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 } -- cgit v1.2.3