]> ruderich.org/simon Gitweb - config/dotfiles.git/blobdiff - lib.sh
herbstluftwm/autostart: add bindings to run programs and select windows
[config/dotfiles.git] / lib.sh
diff --git a/lib.sh b/lib.sh
index bb60c521b959d79ecba52b33dd7e9c4bcd74de36..05341537363b6e2bf19ed44df8bd50c3d184a175 100644 (file)
--- a/lib.sh
+++ b/lib.sh
@@ -101,7 +101,7 @@ simple_cpp() {
             break
         fi
 
-        cmd="$cmd s/\b$x\b/\$ARGV[\$i]/g; \$i++;"
+        cmd="$cmd s/\\b$x\\b/\$ARGV[\$i]/g; \$i++;"
     done
 
     perl_line_filter "$cmd" -- "$@"
@@ -140,7 +140,7 @@ link() {
 
     # Get all necessary paths.
     pwd=`pwd`
-    base=`printf '%s' "$2" | sed "s|\~|$HOME|"` # expand ~, some sh don't do it
+    base=`printf '%s' "$2" | sed "s|~|$HOME|"` # expand ~, some sh don't do it
     base=`dirname "$base"`
     source=`printf '%s' "$pwd/$1" | sed "s|$base/||"`
     target=`basename "$2"`
@@ -168,7 +168,7 @@ link() {
     ln -s "$source" "$target"
 
     # Go back to the directory where we were before.
-    cd "$pwd"
+    cd "$pwd" || return 1
 }
 
 # Generate a file from a source file using a given command. A warning not to
@@ -196,13 +196,15 @@ generate() {
         printf '%s: generating from "%s" (%s)\n' \
             "$file" "$file$extension" "$1"
 
-        echo '###################################'  >"$file"
-        echo '# WARNING! DO NOT EDIT THIS FILE! #' >>"$file"
-        echo '###################################' >>"$file"
-        echo >>"$file"
-        printf '# It was generated from "%s" on %s.\n' \
-            "$file$extension" "`date`" >>"$file"
-        echo >>"$file"
+        {
+            echo '###################################'
+            echo '# WARNING! DO NOT EDIT THIS FILE! #'
+            echo '###################################'
+            echo
+            printf '# It was generated from "%s" on %s.\n' \
+                "$file$extension" "`date`"
+            echo
+        } > "$file"
 
         file_tmp="$file"
     fi