Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

8
  • \$\begingroup\$ The shell grammar does not require a ;; in the last alternative. Use ; to shave off a byte. \$\endgroup\$ Commented Aug 18, 2017 at 7:23
  • 1
    \$\begingroup\$ I've just tried this on bash-2.05a (compiled just now for Cygwin), and it incorrectly reports "3", not "2" :( \$\endgroup\$ Commented Aug 21, 2017 at 9:51
  • 1
    \$\begingroup\$ the interpret-$'\xN feature seems to have been added in 2.01.1... I will have to update my answer. Working on it \$\endgroup\$ Commented Aug 21, 2017 at 10:12
  • \$\begingroup\$ can I ask you to try this? s="$'\ua\xa\n'";case ${#s} in 3)echo 4;;5)echo 3;;7)echo 2;;9)echo 1;esac \$\endgroup\$ Commented Aug 21, 2017 at 10:16
  • 1
    \$\begingroup\$ You might be able to golf this to something like s=$'\ua\xa\n';expr 5 - ${#s} / 2. This works on v3 and v4. I don't have working older versions to try right now. \$\endgroup\$ Commented Jun 20, 2018 at 21:27