blob: e884391e80a1e365239cad21868a709889ec313b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# Aliases apply to the command word, at parse time.
alias hi='echo hello'
hi there
alias
alias hi
alias nothere; echo "status=$?"
# An alias is not expanded inside its own text.
alias echo='echo E:'
echo x
unalias echo
echo y
# A value ending in a blank makes the next word eligible too.
alias run='command ' two='echo 2'
run two
# After an assignment the command word is still an alias candidate.
X=1 hi again
# Quoting any part of the word prevents expansion.
\hi 2>/dev/null; echo "quoted=$?"
'hi' 2>/dev/null; echo "quoted=$?"
# Aliases can produce reserved words and whole constructs.
alias loop='for i in 1 2; do' fin='done'
loop echo $i; fin
alias both='echo a; echo b'
both
# Only the command position: an argument is left alone.
echo hi
# Defined on one line, usable from the next; in a function body the alias
# is expanded when the function is read.
alias later='echo later-1'
f() { later; }
alias later='echo later-2'
f
later
type hi; command -v hi
unalias -a; alias | wc -l | tr -d ' '
unalias nope; echo "status=$?"
alias 'bad name=x'; echo "status=$?"
alias multi='echo m1
echo m2'
multi
alias empty=''
empty
empty echo after-empty
eval 'alias ev="echo from-eval"'
ev
alias hi='echo hello'
x=$(hi sub); echo "$x"
|