1

Is there an accepted name for referring to home directory ~/ paths?

While searching for the answer I found posts which use a variety of terms:

  • ~/ syntax
  • ~/ paths
  • ~/ expanded paths
  • ~/ notation

But I could find no consistently used and convenient term to use for ~/ syntax paths and which may be used to distinguish them from a full absolute path or a relative path.

Please note that I am aware that ~/ paths are absolute paths because the shell expands them - it's a convenient way to refer to them that I am after.

closed as primarily opinion-based by Wildcard, Jeff Schaller, HalosGhost, techraf, G-Man Nov 1 '16 at 7:40

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.

  • From gnu.org/software/bash/manual/html_node/Tilde-Expansion.html: "If a word begins with an unquoted tilde character (‘~’), all of the characters up to the first unquoted slash (or all characters, if there is no unquoted slash) are considered a tilde-prefix. If none of the characters in the tilde-prefix are quoted, the characters in the tilde-prefix following the tilde are treated as a possible login name. If this login name is the null string, the tilde is replaced with the value of the HOME shell variable. …". Apparently things are more complicated than they seem? – phk Oct 31 '16 at 22:05
  • Asking for suggestions and trying to arrive at a consensus here is not the purpose of this site. Recommend removing the last paragraph entirely. Without it, it's a more or less decent question; with it, it's blatantly subjective and opinion-based and therefore off topic. – Wildcard Nov 1 '16 at 2:05
  • I have removed the last paragraph. – mattst Nov 1 '16 at 11:32
1

~/ is only one of several magical "Tilde Expansions". Tilde expansions are particularly associated with UNIX shells. Unlike $HOME tilde expansions are not universally understood and can vary shell by shell. The only commonality is adherence to the POSIX standard (for the most part), and according to Wikipedia the POSIX shell standard is based on a "strict subset" of the Korn Shell, a derivative of the Bourne Shell. Descendants of the Bourne shell notably include bash and zsh. Here's what POSIX says about Tilde Expansions:

A "tilde-prefix" consists of an unquoted character at the beginning of a word, followed by all of the characters preceding the first unquoted in the word, or all the characters in the word if there is no . In an assignment (see XBD Variable Assignment), multiple tilde-prefixes can be used: at the beginning of the word (that is, following the of the assignment), following any unquoted , or both. A tilde-prefix in an assignment is terminated by the first unquoted or . If none of the characters in the tilde-prefix are quoted, the characters in the tilde-prefix following the are treated as a possible login name from the user database. A portable login name cannot contain characters outside the set given in the description of the LOGNAME environment variable in XBD Other Environment Variables. If the login name is null (that is, the tilde-prefix contains only the tilde), the tilde-prefix is replaced by the value of the variable HOME. If HOME is unset, the results are unspecified. Otherwise, the tilde-prefix shall be replaced by a pathname of the initial working directory associated with the login name obtained using the getpwnam() function as defined in the System Interfaces volume of POSIX.1-2008. If the system does not recognize the login name, the results are undefined.

The pathname resulting from tilde expansion shall be treated as if quoted to prevent it being altered by field splitting and pathname expansion.

Basically that means ~ gives the $HOME and ~foo/ links to the initial working directory of user foo. Roughly but not always meaning the home directory of foo. (the only exception I can think of is root)

In BaSH they don't adhere to that standard for tilde expansions in a few ways, none particularly significant. BaSH also has other fun tilde expansions, link courtesy of commenter @phk. You can collect them all!


But I digress. If we're talking about what ~/ is called, I'm not sure if you're referring to the term for the path itself (of the form ~/x/y/z) or for the phenomena of using ~/ to make said path (ie, artwork vs art, derivative vs differentiation). Because ~/ paths and ~/ expanded paths seem to refer to the former and ~/ syntax and ~/ notation to the latter. I'm probably overcomplicating but language is a fickle thing. For instance~/ paths emphasizes the form of the paths as beginning with ~/, while ~/ extended paths emphasizes the function ~/ is performing to create the path of that form.

Anyway, by now you've probably realized that

there is no accepted name

since all of those terms are in circulation and the issue hasn't been given official attention that we know of from the powers that be. Or to put it differently, all of those terms are ways of describing the same thing- not competing labels. They have no formal name but anyone who knows a bit of bash will immediately recognize what they mean- and if people understand what you're talking about, who cares what you call it? You can decide for yourself which term you like. Personally I like ~/ paths, pronounced "tilde-slash paths". And to refer to the phenomena "tilde-slash path shorthand". To be honest I don't even think they need a name...

  • ~ expands to $HOME (not the current working directory) in some contexts in some shells. There are some other ~ expansions depending on the shell like ~user, ~named-dir, ~1, ~[dynamic]... Calling ~/bin a tilde-path makes as little sense as calling $HOME/bin a dollar-path IMO. – Stéphane Chazelas Nov 1 '16 at 11:46
  • I was talking about bash, hence the nod to bash's tilde expansions man page. By default HOME is the working directory. I assumed the OR was specifically referring to ~/, if not then the proper name is "tilde expansions". – trudgemank Nov 1 '16 at 22:28
  • Oh crap, in bash its ~+/ ~-/. Gotta fix answer – trudgemank Nov 1 '16 at 22:53
  • Note that tilde expansion originated in csh (a non-POSIX/non-Bourne shell) in the late 70s. It's ksh that first brought it to the Bourne-like shell world. – Stéphane Chazelas Nov 2 '16 at 9:31
  • I read the wikipedia article :P I was just talking about POSIX standards, but yeah, C-shell did it first. Since we're talking care to take a look at my question? :) unix.stackexchange.com/questions/319958/… freakin tech support at school was a let down. – trudgemank Nov 3 '16 at 6:58

Not the answer you're looking for? Browse other questions tagged or ask your own question.