9 votes

Beware of shell globs

2 comments

  1. ainar-g
    Link
    Heh, nice. Casual reminder that when programming in Shell, the answer to “Did I add enough quotes?” is always “No”.

    Heh, nice. Casual reminder that when programming in Shell, the answer to “Did I add enough quotes?” is always “No”.

    3 votes
  2. vivaria
    (edited )
    Link
    Hah! I was just talking to a friend about something similar an hour ago. I'm in an SENG class that people from all sorts of disciplines take as an intro to UNIX, git, etc. Earlier in the course, *...

    Hah! I was just talking to a friend about something similar an hour ago.

    I'm in an SENG class that people from all sorts of disciplines take as an intro to UNIX, git, etc. Earlier in the course, * was introduced as a wildcard when interacting with the shell (but it wasn't explicitly mentioned as a glob pattern). Now, later in the course, we're learning about regex. Not only was this confusing from a student perspective, but to make matters worse, the prof himself incorrectly interpreted * in a regex pattern as the glob-type of *! It's a bit of a mess, but I think it will work out okay. :)

    If you want to read another cautionary tale about globbing and regex and grep, check out this link, too: https://www.linuxjournal.com/content/globbing-and-regex-so-similar-so-different

    1 vote