summaryrefslogtreecommitdiffstats
path: root/test/bashisms/dynamic-length.sh
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--test/bashisms/dynamic-length.sh9
-rw-r--r--test/bashisms/dynamic-length.sh.out8
2 files changed, 17 insertions, 0 deletions
diff --git a/test/bashisms/dynamic-length.sh b/test/bashisms/dynamic-length.sh
new file mode 100644
index 0000000..fa76729
--- /dev/null
+++ b/test/bashisms/dynamic-length.sh
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+len=1
+f=foo
+
+echo "${f:1}" # BASHISM
+echo "${f:$len}" # BASHISM
+echo "${f:$len$len}" # BASHISM
+echo "${f:${len}}" # BASHISM
diff --git a/test/bashisms/dynamic-length.sh.out b/test/bashisms/dynamic-length.sh.out
new file mode 100644
index 0000000..ffd0b13
--- /dev/null
+++ b/test/bashisms/dynamic-length.sh.out
@@ -0,0 +1,8 @@
+possible bashism in bashisms/dynamic-length.sh line 6 (${foo:3[:1]}):
+echo "${f:1}" # BASHISM
+possible bashism in bashisms/dynamic-length.sh line 7 (${foo:3[:1]}):
+echo "${f:$len}" # BASHISM
+possible bashism in bashisms/dynamic-length.sh line 8 (${foo:3[:1]}):
+echo "${f:$len$len}" # BASHISM
+possible bashism in bashisms/dynamic-length.sh line 9 (${foo:3[:1]}):
+echo "${f:${len}}" # BASHISM