Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This does not change the ambiguity of the language, nor does it remove the need for a prelexer.

Quoting the talk, very quickly...

Which command outputs \\?

  echo "\\\"
  echo "\\\\"
  echo "\\\\\\"
You may see this as a non-event, but the rest of us are not quite comfortable with this.


How is that different from backslash-escaped strings in C, Java, Javascript, Python, and... uh, a whole bunch of other common languages?

Which of those gives you a string with two backslashes in those other languages? Exactly the same one as (ba)sh.


Let's have a more concrete example of ambiguity.

"${*##*[ ]}" is a valid POSIX approach to getting the last parameter but it doesn't work in ksh or bash. Those shells apply the pattern to each parameter in turn when used on '*' or '@'.

That text is from a developer who has profound depth.

A portable method to extract the last argument is:

  for last
  do :
  done
This ambiguity and subtlety is not good.


Counting backslashes is unpleasant in any language, and Bourne shell excluding `...` does not seem worse than any other. Pascal-style quote doubling is the only reasonable alternative I know of, and except for occupying one character instead of two it’s not all that much better. (Also, trick question, because the first line, with its odd number of backslashes, is a syntax error if given on its own.)

More importantly, the difficulties humans have with the language are different from the difficulties computers do, and I was mostly thinking about the latter, what with the mention of LR parsing and everything.


nope, escaping is definitely worse in bash (and all shells) than real languages.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: