equal
deleted
inserted
replaced
18 function cmd_test { |
18 function cmd_test { |
19 log_cmd "$@" |
19 log_cmd "$@" |
20 |
20 |
21 "$@" |
21 "$@" |
22 } |
22 } |
|
23 |
23 ## Execute command, prefixing its output on stdout with given indent prefix. |
24 ## Execute command, prefixing its output on stdout with given indent prefix. |
24 # |
25 # |
25 # indent " " $cmd... |
26 # indent " " $cmd... |
26 # |
27 # |
27 # Output is kept on stdout, exit status is that of the given command. |
28 # Output is kept on stdout, exit status is that of the given command. |
30 |
31 |
31 "$@" | sed "s/^/$indent/" |
32 "$@" | sed "s/^/$indent/" |
32 |
33 |
33 return ${PIPESTATUS[0]} |
34 return ${PIPESTATUS[0]} |
34 } |
35 } |
|
36 |
|
37 ## Execute a command as root, using sudo if required. |
|
38 function cmd_sudo { |
|
39 if [ $UID -eq 0 ]; then |
|
40 cmd "$@" |
|
41 else |
|
42 cmd sudo "$@" |
|
43 fi |
|
44 } |