File: test.backslash_handling

package info (click to toggle)
shellia 5.10
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 792 kB
  • sloc: sh: 7,840; makefile: 34
file content (30 lines) | stat: -rwxr-xr-x 815 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/bash

# try to send 2 backslashes and Return (3 chars)
tst8="\\\\\\\\"
a="$(dash       -c "echo      \"$tst8\"" | wc -c)"
b="$(bash       -c "echo      \"$tst8\"" | wc -c)"
c="$(sh         -c "/bin/echo \"$tst8\"" | wc -c)"
d="$(sh         -c "echo      \"$tst8\"" | wc -c)"
e="$(posh       -c "echo      \"$tst8\"" | wc -c)"
f="$(mksh       -c "echo      \"$tst8\"" | wc -c)"
g="$(busybox sh -c "echo      \"$tst8\"" | wc -c)"

cat <<END
Results: (for shellia 3=OK)
  dash:echo    $a
  bash:echo    $b
  /bin/echo    $c
  echo         $d
  posh:echo    $e
  mksh:echo    $f
  busybox:echo $g
END

[ "$(echo ":$a:$b:$c:$d:$e:$f:$g:" | grep ":2:")" ] && cat <<END
Warning:
  the problem that backslashes are handled different
  in some shells still exists.
Workaround:
  shellia internally uses /bin/echo
END