aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2017-10-04 23:10:05 +0200
committerTeddy Wing2017-10-04 23:10:05 +0200
commit38351c372bf3331986e5392311e4ec377d3c9fe4 (patch)
tree919d9dece393e87498fa4f28e47c25d45166a35d
parentc66735aced2373be9902d35c7f45267c8257ba21 (diff)
parent607b3d30cbeb6b046b54c3d266b32331212392e8 (diff)
downloadqcd-38351c372bf3331986e5392311e4ec377d3c9fe4.tar.bz2
Merge branch 'allow-database-file-to-be-symlinked'
-rwxr-xr-xqcd9
1 files changed, 7 insertions, 2 deletions
diff --git a/qcd b/qcd
index 091ba1a..8453b58 100755
--- a/qcd
+++ b/qcd
@@ -59,8 +59,12 @@ function __qcd_change_shortcut () {
if __qcd_shortcut_exists $shortcut; then
path=$(__qcd_absolute_path "$path")
+ cp $QCD_DATABASE_FILE "${QCD_DATABASE_FILE}.bak"
+
# The `//\//\/` escapes slashes in the path so that `sed` doesn't complain
- sed -i.bak -E "s/^${shortcut} .+$/${shortcut} ${path//\//\\/}/" $QCD_DATABASE_FILE
+ sed -E "s/^${shortcut} .+$/${shortcut} ${path//\//\\/}/" \
+ < "${QCD_DATABASE_FILE}.bak" \
+ > $QCD_DATABASE_FILE
fi
}
@@ -68,7 +72,8 @@ function __qcd_remove_shortcut () {
local shortcut=$1
if __qcd_shortcut_exists $shortcut; then
- sed -i.bak -E "/^${shortcut} .+/d" $QCD_DATABASE_FILE
+ cp $QCD_DATABASE_FILE "${QCD_DATABASE_FILE}.bak"
+ sed -E "/^${shortcut} .+/d" < "${QCD_DATABASE_FILE}.bak" > $QCD_DATABASE_FILE
fi
}