| 1 |
Simple commands: |
| 2 |
|
| 3 |
$ echo foo |
| 4 |
foo |
| 5 |
$ printf 'bar\nbaz\n' | cat |
| 6 |
bar |
| 7 |
baz |
| 8 |
|
| 9 |
Multi-line command: |
| 10 |
|
| 11 |
$ foo() { |
| 12 |
> echo bar |
| 13 |
> } |
| 14 |
$ foo |
| 15 |
bar |
| 16 |
|
| 17 |
Regular expression: |
| 18 |
|
| 19 |
$ echo foobarbaz |
| 20 |
foobar.* (re) |
| 21 |
|
| 22 |
Glob: |
| 23 |
|
| 24 |
$ printf '* \\foobarbaz {10}\n' |
| 25 |
\* \\fo?bar* {10} (glob) |
| 26 |
|
| 27 |
Literal match ending in (re) and (glob): |
| 28 |
|
| 29 |
$ echo 'foo\Z\Z\Z bar (re)' |
| 30 |
foo\Z\Z\Z bar (re) |
| 31 |
$ echo 'baz??? quux (glob)' |
| 32 |
baz??? quux (glob) |
| 33 |
|
| 34 |
Exit code: |
| 35 |
|
| 36 |
$ (exit 1) |
| 37 |
[1] |
| 38 |
|
| 39 |
Write to stderr: |
| 40 |
|
| 41 |
$ echo foo >&2 |
| 42 |
foo |
| 43 |
|
| 44 |
No newline: |
| 45 |
|
| 46 |
$ printf foo |
| 47 |
foo (no-eol) |
| 48 |
$ printf 'foo\nbar' |
| 49 |
foo |
| 50 |
bar (no-eol) |
| 51 |
$ printf ' ' |
| 52 |
(no-eol) |
| 53 |
$ printf ' \n ' |
| 54 |
|
| 55 |
(no-eol) |
| 56 |
$ echo foo |
| 57 |
foo |
| 58 |
$ printf foo |
| 59 |
foo (no-eol) |
| 60 |
|
| 61 |
Escaped output: |
| 62 |
|
| 63 |
$ printf '\00\01\02\03\04\05\06\07\010\011\013\014\016\017\020\021\022\n' |
| 64 |
\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\x0b\x0c\x0e\x0f\x10\x11\x12 (esc) |
| 65 |
$ printf '\023\024\025\026\027\030\031\032\033\034\035\036\037\040\047\n' |
| 66 |
\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f ' (esc) |
| 67 |
$ echo hi |
| 68 |
\x68\x69 (esc) |
| 69 |
$ echo '(esc) in output (esc)' |
| 70 |
(esc) in output (esc) |
| 71 |
$ echo '(esc) in output (esc)' |
| 72 |
(esc) in output \x28esc\x29 (esc) |
| 73 |
|
| 74 |
Command that closes a pipe: |
| 75 |
|
| 76 |
$ cat /dev/urandom | head -1 > /dev/null |
| 77 |
|
| 78 |
If Cram let Python's SIGPIPE handler get inherited by this script, we |
| 79 |
might see broken pipe messages. |