Live data from Hacker News

Start all of your commands with a comma (2009)

rhodesmill.org

91–100 of 252 posts

Re: Start all of your commands with a comma (2009)

#92
post #76
post #72

Earlier quoted context omitted.

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

Re: Start all of your commands with a comma (2009)

#93
post #51

Using commas in filenames feels kind of weird to me, but I do use a comma as the initiator for my Bash key sequences. For example: ,, expands to $ ,h expands to --help ,v expands to --version ,s prefixes sudo You put keyseqs in ~/.inputc, set a keyseq-timeout, and it just works.

also. did you mean .inputrc ?

Re: Start all of your commands with a comma (2009)

#94
post #92
post #76

Earlier quoted context omitted.

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

Imagine seeing this code:

    echo file{",",",,",",,,"}.txt

Re: Start all of your commands with a comma (2009)

#95
Glad it worked for OP, but I've never once in 30+ years of this had a conflict that did something I didn't want. ~/bin/ is early in my PATH, and for a good reason. Things I put in there I want to take precedence, so I use this to purposely override provided bins. (Though I can only think of one time I wanted to do that, too.)

Re: Start all of your commands with a comma (2009)

#96
post #27

Why so many people use ~/bin/? What’s wrong with ~/.local/bin?

Personally I use ~/opt//bin where ~/opt is a ‘one stop shop’ containing various things, including a symlink to ~/local and directories or symlinks for things that don't play well with others (e.g. cargo, go), and an ~/opt/prefer/bin that goes at the start of PATH containing symlinks to resolve naming conflicts.

(Anything that modifies standard behaviour is not in PATH, but instead a shell function present only in interactive shells, so as not to break scripts.)

Unix lore: Early unix had two-letter names for most common names to make them easy to type on crappy terminals, but no one* letter command names because the easier were reserved for personal use.

Re: Start all of your commands with a comma (2009)

#98
post #87

I appreciate the idea, but the comma just looks horrible to me as part of a filename. I can imagine someone unfamiliar with the naming scheme to get confused. I'd prefer to use underscore (when writing BASH scripts, I name all my local variables starting with underscore), but a simple two or three letter prefix would also work. I don't like the idea of a punctuation prefix as punctuation usually has a specific meanin…

Underscore requires pressing Shift, however. > I don't like the idea of a punctuation prefix as punctuation usually has a specific meaning somewhere and including it as the first character in a filename looks wrong. So you don’t use dotfiles? ;)

Well dotfiles demonstrate that punctuation can have a special meaning in filenames.

I'm not convinced by "quicker to type" arguments as that's rarely the bottleneck, so I'm perfectly happy with using underscores in filenames and variables. I wouldn't use underscore as the beginning character of a filename unless it had a specific meaning to me (e.g. temporary files), so I'd be more inclined to use a two or three character prefix instead.

Re: Start all of your commands with a comma (2009)

#100

I didn't like the idea. I prefer the alternative approach: _I_ decide the order of dirs in the PATH env. If I introduce an executable with a name, that overrides a system one - I probably do that intentionally. If I introduce an alias (like `grep='grep --binary-files=without-match --ignore-case --color=auto`) that matches the name of a system binary - I probably do that intentionally. And if I EVER need to call grep…

Looked so backwards to me, too. However, I decided to give it a go, anyway. Now, I have some scripts and small commands which start with a comma, and it looks neat and time saving.

Yes, I can do path ordering to override usual commands. However, having a set of odd-job scripts which start with a comma gives a nice namespacing capability alongside a well narrowed-down tab-completion experience.

While it's not the neatest thing around, it works surprisingly well.

Another idea which looks useless until you start using is text expanders (i.e.: Espanso and TextExpander).

Post reply on HN