Live data from Hacker News

Start all of your commands with a comma (2009)

rhodesmill.org

121–130 of 177 posts

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

#121
post #19

> Because my shell script names tended to be short and pithy collections of lowercase characters, just like the default system commands, there was no telling when Linux would add a new command that would happen to have the same name as one of mine. Not sure I understand this problem. I just put my bin directory at the front of $PATH rather than the end. To browse my commands, I simply `ls ~/bin`.

But then you start using some tool that expects $0 in the system path and breaks causing frustration and debugging. Pick your poison

In 35 years of using Unix I've never come across anything like this. What tool do you use that this is an issue?

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

#124

I use short custom command names like aa, st, di, dp, cm and le in some thin wrappers around git. One of these names actually collides with a utility that is installed by default on some systems. Doesn’t matter to me. I have my own bin dirs before the system dirs in my path, so mine “win”, and I’m not really interested at all in the tool that mine has a name collision with. If someone were to make a useful to me tool…

Hot take: system commands shouldn't be as accessible as user commands. There should be some sort of namespacing. For example, mkfs should be invoked with `sys::mkfs` or something like that.

The line that separates system and user commands may be defined in different ways, and it may be fuzzy in some places, but if a user accidentally invokes a command that they don't even know why is there, and they didn't explicitly install, then that's clearly a command that shouldn't be directly available in the global namespace.

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

#125

Earlier quoted context omitted.

Surely ,nds?

I think "comma_nds" ("commands" if you remove the underscore) makes the pun mkre obvious. I didn't get it at first thought, thinking of the .nds file extension for Nintendo DS ROMs.

The pun still holds as "comma,nds" though, and might even do so better.

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

#126

> Because my shell script names tended to be short and pithy collections of lowercase characters, just like the default system commands, there was no telling when Linux would add a new command that would happen to have the same name as one of mine. Not sure I understand this problem. I just put my bin directory at the front of $PATH rather than the end. To browse my commands, I simply `ls ~/bin`.

I just… remember the names I give things? Why is this considered a “hack” of some kind?

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

#127

A kinda relevant question. I use Windows most of time. Like the author, I have bunch of CLI scripts (in Python mainly) which I put into my ~/bin/ equivalent. After setting python.exe as the default program for `.py` extension, and adding `.py` to `%pathext%`, I can now run my ~/bin/hello.py script at any path by just type `hello`, which I use hundreds of time a day. I now use Linux more and more (still a newbie) but…

Linux has a feature called 'binfmt_misc' which allows you to associate an interpreter to run when a file of any arbitrary format is invoked like an executable. You have to tell the kernel which extension or format is associated with which interpreter, but this is easily done in a startup script.

You still have to say '.py' at the end, though.

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

#129
I’ve used this method for a while now, not sure if it’s from this particular article or if someone else blogged the same idea. I also prefix any aliases or sh functions from my rc file with a comma. Mostly it gets me easy to find custom commands when I “forget what I called that one alias”.

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

#130

I use short custom command names like aa, st, di, dp, cm and le in some thin wrappers around git. One of these names actually collides with a utility that is installed by default on some systems. Doesn’t matter to me. I have my own bin dirs before the system dirs in my path, so mine “win”, and I’m not really interested at all in the tool that mine has a name collision with. If someone were to make a useful to me tool…

This approach can lead to issues like `apt-get upgrade` launching dwarf fortress: https://askubuntu.com/questions/938606/dwarf-fortress-starti...

I hope that tools like apt-get run subcommands in a predictable environment and never leak interactive session's $PATH. Then nothing in $HOME will break them — that user just put his df executable in /usr/bin or somewhere like that.
Post reply on HN