Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
syntax:expansion:tilde [2009/02/24 06:26]
127.0.0.1 external edit
syntax:expansion:tilde [2017/03/05 18:07] (current)
fgrose [Tilde expansion] punctuation
Line 24: Line 24:
 Tilde expansion is only performed, when the tilde-construct is at the beginning of a word, or a separate word. Tilde expansion is only performed, when the tilde-construct is at the beginning of a word, or a separate word.
  
-If there'​s nothing to expand, i.e. in case of a wrong username or any other error condition, the tilde construct is not replaced, it stays what it is.+If there'​s nothing to expand, i.e.in case of a wrong username or any other error condition, the tilde construct is not replaced, it stays what it is.
  
 Tilde expansion is also performed everytime a variable is assigned: Tilde expansion is also performed everytime a variable is assigned:
Line 31: Line 31:
  
 <note info> <note info>
-As of now (September 2008) the following constructs **also** works, though it's not a variable assignment:+As of now (Bash 4.3-alpha) the following constructs **also** works, though it's not a variable assignment:
 <​code>​ <​code>​
 echo foo=~ echo foo=~
Line 39: Line 39:
 </​note>​ </​note>​
  
-This way you can correctly use the tilde expansion in your ''​PATH''​:+This way you can correctly use the tilde expansion in your [[syntax:​shellvars#​PATH|PATH]]:
 <​code>​ <​code>​
 PATH=~/​mybins:​~peter/​mybins:​$PATH PATH=~/​mybins:​~peter/​mybins:​$PATH
Line 61: Line 61:
  
 To find the home directory of the current user (''​~''​),​ Bash has a precedence: To find the home directory of the current user (''​~''​),​ Bash has a precedence:
-  * expand to ''​$HOME'' ​if it's defined+  * expand to the value of [[syntax:​shellvars#​HOME|HOME]] ​if it's defined
   * expand to the home directory of the user executing the shell (operating system)   * expand to the home directory of the user executing the shell (operating system)
-That means, ''​HOME''​ can override the "​real"​ home directory, at least regarding tilde expansion.+That means, ​the variable ​''​HOME''​ can override the "​real"​ home directory, at least regarding tilde expansion.
  
  
Line 71: Line 71:
 </​code>​ </​code>​
  
-This expands to the value of the ''​PWD'' ​variable, which holds the currect working directory:+This expands to the value of the [[syntax:​shellvars#​PWD|PWD]] ​variable, which holds the currect working directory:
 <​code>​ <​code>​
 echo "CWD is $PWD" echo "CWD is $PWD"
Line 87: Line 87:
 </​code>​ </​code>​
  
-This expands to the value of the ''​OLDPWD'' ​variable, which holds the previous working directory (the one before the last ''​cd''​). If ''​OLDPWD''​ is unset (never changed the directory), it is not expanded.+This expands to the value of the [[syntax:​shellvars#​OLDPWD|OLDPWD]] ​variable, which holds the previous working directory (the one before the last ''​cd''​). If ''​OLDPWD''​ is unset (never changed the directory), it is not expanded.
  
 <​code>​ <​code>​
  • syntax/expansion/tilde.1235456763.txt
  • Last modified: 2011/06/04 15:20
  • (external edit)