Re: Should nested case statements within command substitutions work on in bash 3.2.x?
Thanks for reply and the workaround. jon. On Sun, Mar 22, 2015 at 4:49 PM, Chris F.A. Johnson ch...@cfajohnson.com wrote: On Sun, 22 Mar 2015, Jon Seymour wrote: I was surprised that this didn't work with the OSX version of bash 3.2: /bin/bash -c 'echo $(case yes in yes) echo yes; ;; no) echo no; ;; esac)' /bin/bash: -c: line 0: syntax error near unexpected token `;;' /bin/bash: -c: line 0: `echo $(case yes in yes) echo yes; ;; no) echo no; ;; esac)' It does work with bash 4.x. Is this a known issue with 3.2 or is it particular to the OSX implementation (which in my case is 3.2.53(1))? Balance the parentheses: echo $(case yes in (yes) echo yes; ;; (no) echo no; ;; esac) -- Chris F.A. Johnson, http://cfajohnson.com
Re: Should nested case statements within command substitutions work on in bash 3.2.x?
On Sun, 22 Mar 2015, Jon Seymour wrote: I was surprised that this didn't work with the OSX version of bash 3.2: /bin/bash -c 'echo $(case yes in yes) echo yes; ;; no) echo no; ;; esac)' /bin/bash: -c: line 0: syntax error near unexpected token `;;' /bin/bash: -c: line 0: `echo $(case yes in yes) echo yes; ;; no) echo no; ;; esac)' It does work with bash 4.x. Is this a known issue with 3.2 or is it particular to the OSX implementation (which in my case is 3.2.53(1))? Balance the parentheses: echo $(case yes in (yes) echo yes; ;; (no) echo no; ;; esac) -- Chris F.A. Johnson, http://cfajohnson.com
Should nested case statements within command substitutions work on in bash 3.2.x?
I was surprised that this didn't work with the OSX version of bash 3.2: /bin/bash -c 'echo $(case yes in yes) echo yes; ;; no) echo no; ;; esac)' /bin/bash: -c: line 0: syntax error near unexpected token `;;' /bin/bash: -c: line 0: `echo $(case yes in yes) echo yes; ;; no) echo no; ;; esac)' It does work with bash 4.x. Is this a known issue with 3.2 or is it particular to the OSX implementation (which in my case is 3.2.53(1))? jon.
Re: Should nested case statements within command substitutions work on in bash 3.2.x?
Jon Seymour wrote: I was surprised that this didn't work with the OSX version of bash 3.2: /bin/bash -c 'echo $(case yes in yes) echo yes; ;; no) echo no; ;; esac)' /bin/bash: -c: line 0: syntax error near unexpected token `;;' /bin/bash: -c: line 0: `echo $(case yes in yes) echo yes; ;; no) echo no; ;; esac)' It does work with bash 4.x. It was improved later. But I see that zsh as of 5.0.7 still has the same problem with that construct. Is this a known issue with 3.2 or is it particular to the OSX implementation (which in my case is 3.2.53(1))? It is that way in 3.2 and not specific to your OS X implementation. Of course you know that if you match the parens then it will parse correctly. Matching parens has been the standard way to handle this case for all of the shells. $ bash -c 'echo $(case yes in (yes) echo yes ;; (no) echo no ;; esac)' yes Bob