fork/fish-shell

git clone https://git.julia.blue/fork/fish-shell

Johannes AltmanningerFix section names in suggested "help" commands4ffa06fb7

master
2.7 KiB91 linesraw
1#RUN: %fish %s
2set -l filename (echo foo | psub --testing)
3test -f $filename
4or echo 'psub is not a regular file' >&2
5rm $filename
6
7set -l filename (echo foo | psub --testing --file)
8test -f $filename
9or echo 'psub is not a regular file' >&2
10rm $filename
11
12set -l filename (echo foo | psub --testing --fifo)
13test -p $filename
14or echo 'psub is not a fifo' >&2
15# hack: the background write that psub performs may block
16# until someone opens the fifo for reading. So make sure we
17# actually read it.
18cat $filename >/dev/null
19rm $filename
20
21cat (echo foo | psub)
22cat (echo bar | psub --fifo)
23cat (echo baz | psub)
24#CHECK: foo
25#CHECK: bar
26#CHECK: baz
27
28set -l filename (echo foo | psub)
29if test -e $filename
30    echo 'psub file was not deleted'
31else
32    echo 'psub file was deleted'
33end
34#CHECK: psub file was deleted
35
36# The --file flag is the default behavior.
37if count (echo foo | psub -s .cc | string match -r '\.cc$') >/dev/null
38    echo 'psub filename ends with .cc'
39else
40    echo 'psub filename does not end with .cc'
41end
42#CHECK: psub filename ends with .cc
43
44# Make sure we get the same result if we explicitly ask for a temp file.
45if count (echo foo | psub -f -s .cc | string match -r '\.cc$') >/dev/null
46    echo 'psub filename ends with .cc'
47else
48    echo 'psub filename does not end with .cc'
49end
50#CHECK: psub filename ends with .cc
51
52# Fifo is allowed to have a suffix as well
53# hack: the background write that psub performs may block
54# until someone opens the fifo for reading. So make sure we
55# actually read it.
56if cat (echo foo | psub -F -s .cc | string match -e -r '\.fifo\.cc$') >/dev/null
57    echo 'psub pipe name ends with .cc'
58else
59    echo 'psub pipe name does not end with .cc'
60end
61#CHECK: psub pipe name ends with .cc
62
63set -l filename (echo foo | psub -s .fish)
64if test -e (dirname $filename)
65    echo 'psub directory was not deleted'
66else
67    echo 'psub directory was deleted'
68end
69#CHECK: psub directory was deleted
70
71set -l diffs (comm -3 (__fish_print_help psub 2>| psub) (psub -hs banana 2>| psub))
72test -z "$diffs"
73
74# In cases that look like process substitutions, mention psub.
75
76echo <(seq 0)
77# CHECKERR: {{.*}}/psub.fish (line {{\d+}}): Invalid redirection target:
78# CHECKERR: echo <(seq 0)
79# CHECKERR:      ^~~~~~~^
80# CHECKERR: If you wish to use process substitution, consider the psub command, see: `help cmds/psub`
81
82# To-do: should also mention psub here.
83echo <(seq 1)
84# CHECKERR: warning: An error occurred while redirecting file '1'
85# CHECKERR: warning: Path '1' does not exist
86
87echo <(seq 2)
88# CHECKERR: {{.*}}/psub.fish (line {{\d+}}): Invalid redirection target:
89# CHECKERR: echo <(seq 2)
90# CHECKERR:      ^~~~~~~^
91# CHECKERR: If you wish to use process substitution, consider the psub command, see: `help cmds/psub`