lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [lmi] master b8f724e 4/4: Remove zshisms


From: Greg Chicares
Subject: [lmi-commits] [lmi] master b8f724e 4/4: Remove zshisms
Date: Mon, 13 May 2019 21:46:22 -0400 (EDT)

branch: master
commit b8f724eba2c05936dcbfe4b53f3aa0c188af7abb
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>

    Remove zshisms
    
    Brace expansion had made this script dependent on zsh, which meant that
    it couldn't be validated by 'shellcheck'.
---
 mst_to_xst.sh | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/mst_to_xst.sh b/mst_to_xst.sh
index aa1344c..03e1b6a 100755
--- a/mst_to_xst.sh
+++ b/mst_to_xst.sh
@@ -1,4 +1,4 @@
-#!/bin/zsh
+#!/bin/sh
 
 # Copy MST files, obfuscating them for distribution.
 
@@ -30,15 +30,26 @@
 # Stripping the copyright header before obfuscation is a possible
 # future enhancement that might improve runtime performance.
 
-# This script requires zsh because brace expansion is more convenient
-# than 'seq'. It is intended to be called from a makefile that sets
+# This script is intended to be called from a makefile that sets
 # both $datadir and $srcdir.
 
+seqq()
+{
+    first=$1 incr=$2 last=$3
+    echo "for (i = $first; i != $last+$incr; i+=$incr) i" | bc -l
+}
+
+# These variables are indeed not assigned here.
+# shellcheck disable=SC2154
 [ -d "$datadir" ] || { printf 'fail: invalid datadir\n'; exit 2; }
+# shellcheck disable=SC2154
 [ -d "$srcdir"  ] || { printf 'fail: invalid srcdir\n';  exit 3; }
 
-X=$(printf '\%03o' {255..0})
-Y=$(printf '\%03o' {0..255})
+# Word splitting is not a concern here.
+# shellcheck disable=SC2046
+X=$(printf '\\%03o' $(seqq '255' '-1'   '0'))
+# shellcheck disable=SC2046
+Y=$(printf '\\%03o' $(seqq   '0'  '1' '255'))
 
 cd "$srcdir" || { printf 'fail: cd\n'; exit 4; }
 for z in *.mst; do tr "$X" "$Y" <"$z" >"$datadir/${z%%.mst}.xst"; done



reply via email to

[Prev in Thread] Current Thread [Next in Thread]