Skip to main content

Timeline for Determine your language's version

Current License: CC BY-SA 4.0

12 events
when toggle format what by license comment
Dec 9, 2022 at 8:55 comment added IY5dVSjABEeV why not replace expr with exit $[5-${#s}/2] to output via exit code to golf off?
Jun 21, 2018 at 9:18 history edited joH1 CC BY-SA 4.0
Inject DigitalTrauma's `expr` version
Jun 21, 2018 at 9:10 comment added joH1 @DigitalTrauma nice! the only new mechanism here is expr, so unless it was upgraded between Bash versions, this should work as well as mine (which I still haven't tested on v1 and v2)
Jun 20, 2018 at 21:27 comment added Digital Trauma 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.
Nov 23, 2017 at 3:59 history edited MD XF CC BY-SA 3.0
added 1 character in body
Aug 23, 2017 at 10:21 comment added Jason Musgrove Sorry for delay. Nothing is returned. The length of $s appears to be 11 - the literal content of the quoted string. This also appears to be the case in bash 4.4.12
Aug 21, 2017 at 10:16 comment added joH1 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
Aug 21, 2017 at 10:12 comment added joH1 the interpret-$'\xN feature seems to have been added in 2.01.1... I will have to update my answer. Working on it
Aug 21, 2017 at 9:51 comment added Jason Musgrove I've just tried this on bash-2.05a (compiled just now for Cygwin), and it incorrectly reports "3", not "2" :(
Aug 18, 2017 at 7:37 history edited joH1 CC BY-SA 3.0
added credit for golfed away char
Aug 18, 2017 at 7:23 comment added Jens The shell grammar does not require a ;; in the last alternative. Use ; to shave off a byte.
Aug 17, 2017 at 15:27 history answered joH1 CC BY-SA 3.0