oils-for-unix / oils

Oils is our upgrade path from bash to a better language and runtime. It's also for Python and JavaScript users who avoid shell!
http://www.oilshell.org/
Other
2.85k stars 159 forks source link

[YSH] `write` is a command name already taken in unix environments #2100

Open bar-g opened 1 month ago

bar-g commented 1 month ago

I learned about a feature of unix systems: Shell scripts can write notifications to specific user's sessions by calling the write command since 1971 https://en.wikipedia.org/wiki/Write_(Unix).

And indeed I found it pre-installed on linux:

$ which write
/usr/bin/write

Maybe being a good shell, YSH should choose another name for a replacement command to echo. One that does not conflict with useful existing unix features (chatting between users, or scripts writing to specific terminals).

https://www.geeksforgeeks.org/write-command-in-linux-with-examples/ https://phoenixnap.com/kb/write-command-in-linux

bar-g commented 1 month ago

Could it make sense to have a test checking for existence of ysh commands?

andychu commented 4 weeks ago

Hmm one workaround will be extern write

I haven't heard this complaint yet, but we can see

pass was removed because of a conflict in the past

bar-g commented 4 weeks ago

Seems in the unix environment picture echo is for stdout, while write <user> is for wherever the users "interactive" (notification) terminal currently is.

Could even become more useful when considering headless shell daemons, or multiple long running (maybe bernstein-chained) scripts doing (mostily unnoticed) logging and occasionally user notifications (with the user able to quickly answer back or to communicate anytime needed via write <service>).

So, a unix shell that required to use extern write may somehow stand out as standing in the way of users, besides requiring special adaptions in scripts that use this unix user notification and interaction facility.