297 points · by janvdberg · 6y ago · 61 comments
> [Unix: from `runcom files' on the CTSS system 1962-63, via the startup script /etc/rc] Script file containing startup instructions for an application program (or an entire operating system), usually a text file containing commands of the sort that might have been invoked manually once the system was running but are to be executed automatically each time the system starts up. See also dot file, profile (sense 1).
"rc-file" does not seem to be present pre-ESR, however: https://jargon-file.org/archive/jargon-1.0.3.dos.txt
The gnu project was developed on a vax running Unix that somehow had been installed at the AI lab. Nobody used it so RMS decided to use it as a development machine. We had our own OSes, languages, and hardware and at that point in time Unix offered significantly less power for a large investment of effort.
https://github.com/freebsd/freebsd/blob/master/sbin/init/ini...
Not to be confused with zombocom.
.profile is only for login sessions, .shrc is sourced on every shell fork, about 1000x more than .profile.
For example, do you want to make an autoloaded function named "foo" that comes into existence the first time you call it? Write a file named ~/.config/fish/functions/foo.fish, and inside it define a function named "foo". There - done.
Follow this pattern to make a function named "fish_greeting", and it will run every time you launch a new fish shell. Want to make a custom prompt? Write a function named "fish_prompt". Decide you want one of those fancy prompts where the timestamp is displayed on the right side of your terminal window? Make a "fish_right_prompt.fish" file and put in it:
function fish_right_prompt --description 'Write out the right prompt'
set_color 666666
date +'%Y-%m-%d %H:%M:%S'
set_color normal
end
After years of customizing bash (and later zsh), this is a breath of fresh air.* There are two scripts run by a login shell, $HOME/.profile and /etc/profile .
* These scripts set up environment variables and other things (e.g. umask) to be inherited by the whole login session.
* They, specifically, optionally set an ENV variable whose value names a third script that is run by every interactive shell, including the interactive login shell.
That's exactly three scripts: one for the system administrator and another one for the user to set up login-session-wide stuff, and one for the user to set up this-interactive-shell stuff (such as the shell variables for fancy prompts, completion settings, command-line editing stuff, useful interactive shell aliases, and whatnot). They are always in the same order. And they are simply based upon two things: whether the shell is a login shell, and whether the shell is an interactive shell.
The C shell mechanism is similarly simple, on its own.
The complexity mainly comes from the fact that the Bourne Again shell and the Z shell, amongst others, have multiple mechanisms mixed together and extensions. They look for scripts that are specifically in their own shell languages rather than potentially shared with other shells; .zprofile and .bash_profile instead/ahead of .profile , for example. They have extra scripts that mirror the C shell way of doing things; .zlogin, .zlogout, .bash_login, .bash_logout, .bashrc, and .zshrc, for example. They have idiosyncratic and non-strictly-standard ways of deciding what constitutes an interactive shell. They have mechanisms for disabling the extensions, and ways to come up in alternative not-strictly-conformant sh-compatible modes.
info bash -n "Bash Startup Files"
https://www.gnu.org/software/bash/manual/html_node/Bash-Star...Maybe unlikely but maybe still, this is one of those things how language evolves where a word/suffix has an original meaning that is lost in the practical use day today.
Well, at least! I had no idea the meaning behind it, and it amazes me how I never think it about it.
"The .rc Suffix (Origin Story)
Most UNIX commands use the suffix rc for the name of configuration files. According to Wikipedia, this extension isn’t an acronym for “resource configuration” or “runtime configuration” but comes from a command called RUNCOM.
RUNCOM was created by Louis Pouzin for the Compatible Time-Sharing System (CTSS), which was one of the first time-sharing operating systems. RUNCOM was used to execute a series of commands in succession—a precursor to what we now call a shell script.
He is even credited with coining the term shell, as he describes in a post on the Internet from 2000 on the origins of the shell:
'After having written dozens of commands for CTSS, I reached the stage where I felt that commands should be usable as building blocks for writing more commands, just like subroutine libraries. Hence, I wrote “RUNCOM”, a sort of shell driving the execution of command scripts, with argument substitution. The tool became instantly most popular [sic], as it became possible to go home in the evening while leaving behind long runcoms executing overnight.
Without being invited on the subject, I wrote a paper explaining how the Multics command language could be designed with [the] objective [of using commands somehow like a programming language]. And I coined the word “shell” to name it.'
Although RUNCOM (and CTSS) has long-been retired from regular use, its legacy lives on both as the name for user-specific configuration files and as the basis for the UNIX start-up scripts, typically located in /etc/rc.d."
[0] https://pragprog.com/book/dccar2/build-awesome-command-line-...
r 13:41 0.055 7
ls >sc1>system_start_up.ec
Segments = 1, Lengths = 2.
r w 2 system_start_up.ec
The comments are more interesting than the Wikipedia article...
In source code sometimes a longer name really helps, but then some people take it to the extreme and make everything look pretty ugly and tedious to work with.
In this case, I guess it would not had been that bad to name the files `.bash.runcommands`. `.bourne-again-shell.run-commands`: maybe too much :-)
Just google for "rc unix meaning", as I did. Have to acknowledge I didn't know it either. But now we all know. Good question.
Edit: more info here, https://en.wikipedia.org/wiki/Run_commands .
FYI, the link mentions not only 'run commands' but also 'resource control', 'run control', and 'runtime configuration'.
Instead of bashing a stranger to google, reading the link might be more productive.
I checked in my copy of the jargon file (which I downloaded in August 2001) and got:
rc file /R-C fi:l/ n.
[Unix: from `runcom files' on the CTSS system 1962-63, via the startup script /etc/rc] Script file containing startup instructions for an application program (or an entire operating system), usually a text file containing commands of the sort that might have been invoked manually once the system was running but are to be executed automatically each time the system starts up. See also dot file, profile (sense 1)