Comment by tomcam

20 days ago

    Every tool and shell that lay in arm's reach treated the comma as a perfectly normal and unobjectionable character in a filename.

WTF. After 40 years maybe I should have figured that one out.

It's not a completely non special character: for instance in bash it's special inside braces in the syntax where "/{,usr/}bin" expands to "/bin /usr/bin". But the need to start that syntax with the open brace will remind you about the need to escape a literal comma there if you ever want one.

You never used CVS/RCS with its “,v” files?

  • My introduction to RCS was indeed spurred by a command typo!

    I was learning Pascal on AT&T 3B2 systems. They were running SVR3. Perfectly normal clustered systems with nifty things like RFS. We were all logged in via dumb terminals, and the machines were sequestered on another floor. I had pictured them as big, really big. But 3B2s were not.

    Anyway, our first lessons were how to use the Bourne shell and how to use "vi" to edit our source code.

    I had learned to type 4 years previously, so I was already fast and fearsomely accurate. But I still made mistakes.

    So one day I typed "ci filename.p" and then I had an hour's worth of sheer horror!

    "ci" had not spawned the visual editor as I had hoped, but it did something inexplicable to that file! It had renamed it to "filename.p,v" and had put a bunch of garbage into it!

    I can't remember how much "RCS garbage" was inserted, or how much cleanup I needed to do. For some reason, our TA/lab assistants were not available for me to ask! I was in a cold sweat, because all my hard classwork had been utterly mangled by this unfeeling machine, and I didn't know how to effectively undo it.

    Eventually I learned about the RCS system, and what those curious "$...$" symbols meant, and I think I worked out a way to "undo" it (which I think consisted of merely "co" to checkout the file again.)

    But it was a rude awakening to the fact that simple command-line typos could have some very unintended consequences!

What about using the filename in arrays in bash/sh?

  • But Bash arrays don’t use comma, what’s the problem?

    • Oh, that might be true, I do remember encountering some escaping issues when creating a more complex POSIX (or bash) script that involved lists and iterating through stuff.

      I see Bash only uses commas in Brace expansions:

      file{1,2,3}.txt # file1.txt file2.txt file3.txt

      I guess it would only be a problem if you want to expand

          file,.txt   
          file,,.txt   
          file,,,.txt

      2 replies →