commit cd63924da6e212b5672724b422eadbc71bf4e614
parent 93f44ca841be46cc02f3c95a71c731804fc5fd81
Author: Mattias Andrée <maandree@kth.se>
Date: Mon, 16 Jan 2017 08:03:21 +0100
blind-rotate-*: support arbitrary paths
Only an idiot would use <newline> in paths, but
let's support it anyway (for fun).
Diffstat:
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/blind-rotate-180 b/blind-rotate-180
@@ -12,7 +12,7 @@ if ! test $# = 0; then
fi
fi
-flip="$(printf '%s\n' "$0" | sed 's/[^/]*$/blind-flip/')"
-flop="$(printf '%s\n' "$0" | sed 's/[^/]*$/blind-flop/')"
+flip="$(printf '%s\n' "$0" | tr '/\n' '\n/' | sed '$s/^.*$/blind-flip\//' | tr '/\n' '\n/')"
+flop="$(printf '%s\n' "$0" | tr '/\n' '\n/' | sed '$s/^.*$/blind-flop\//' | tr '/\n' '\n/')"
"$flip" | "$flop"
diff --git a/blind-rotate-270 b/blind-rotate-270
@@ -12,7 +12,7 @@ if ! test $# = 0; then
fi
fi
-transpose="$(printf '%s\n' "$0" | sed 's/[^/]*$/blind-transpose/')"
-flop="$( printf '%s\n' "$0" | sed 's/[^/]*$/blind-flop/')"
+transpose="$(printf '%s\n' "$0" | tr '/\n' '\n/' | sed '$s/^.*$/blind-transpose\//' | tr '/\n' '\n/')"
+flop="$( printf '%s\n' "$0" | tr '/\n' '\n/' | sed '$s/^.*$/blind-flop\//' | tr '/\n' '\n/')"
"$flop" | "$transpose"
diff --git a/blind-rotate-90 b/blind-rotate-90
@@ -12,7 +12,7 @@ if ! test $# = 0; then
fi
fi
-transpose="$(printf '%s\n' "$0" | sed 's/[^/]*$/blind-transpose/')"
-flop="$( printf '%s\n' "$0" | sed 's/[^/]*$/blind-flop/')"
+transpose="$(printf '%s\n' "$0" | tr '/\n' '\n/' | sed '$s/^.*$/blind-transpose\//' | tr '/\n' '\n/')"
+flop="$( printf '%s\n' "$0" | tr '/\n' '\n/' | sed '$s/^.*$/blind-flop\//' | tr '/\n' '\n/')"
"$transpose" | "$flop"