6
6
7
7
valgrind_off = ccall (:jl_running_on_valgrind , Cint, ()) == 0
8
8
9
- yes = ` yes`
10
- echo = ` echo`
9
+ yescmd = ` yes`
10
+ echocmd = ` echo`
11
11
sortcmd = ` sort`
12
- printf = ` printf`
12
+ printfcmd = ` printf`
13
13
truecmd = ` true`
14
14
falsecmd = ` false`
15
15
catcmd = ` cat`
16
16
shcmd = ` sh`
17
17
sleepcmd = ` sleep`
18
+ lscmd = ` ls`
18
19
if is_windows ()
19
20
try # use busybox-w32 on windows
20
21
success (` busybox` )
21
- yes = ` busybox yes`
22
- echo = ` busybox echo`
22
+ yescmd = ` busybox yes`
23
+ echocmd = ` busybox echo`
23
24
sortcmd = ` busybox sort`
24
- printf = ` busybox printf`
25
+ printfcmd = ` busybox printf`
25
26
truecmd = ` busybox true`
26
27
falsecmd = ` busybox false`
27
28
catcmd = ` busybox cat`
28
29
shcmd = ` busybox sh`
29
30
sleepcmd = ` busybox sleep`
31
+ lscmd = ` busybox ls`
30
32
end
31
33
end
32
34
33
35
# ### Examples used in the manual ####
34
36
35
- @test readstring (` $echo hello \| sort` ) == " hello | sort\n "
36
- @test readstring (pipeline (` $echo hello` , sortcmd)) == " hello\n "
37
- @test length (spawn (pipeline (` $echo hello` , sortcmd)). processes) == 2
37
+ @test readstring (` $echocmd hello \| sort` ) == " hello | sort\n "
38
+ @test readstring (pipeline (` $echocmd hello` , sortcmd)) == " hello\n "
39
+ @test length (spawn (pipeline (` $echocmd hello` , sortcmd)). processes) == 2
38
40
39
- out = readstring (` $echo hello` & ` $echo world` )
41
+ out = readstring (` $echocmd hello` & ` $echocmd world` )
40
42
@test search (out," world" ) != 0 : - 1
41
43
@test search (out," hello" ) != 0 : - 1
42
- @test readstring (pipeline (` $echo hello` & ` $echo world` , sortcmd)) == " hello\n world\n "
44
+ @test readstring (pipeline (` $echocmd hello` & ` $echocmd world` , sortcmd)) == " hello\n world\n "
43
45
44
- @test (run (` $printf " \0 33[34m[stdio passthrough ok]\0 33[0m\n "` ); true )
46
+ @test (run (` $printfcmd " \0 33[34m[stdio passthrough ok]\0 33[0m\n "` ); true )
45
47
46
48
# Test for SIGPIPE being treated as normal termination (throws an error if broken)
47
- is_unix () && run (pipeline (yes , ` head` , DevNull))
49
+ is_unix () && run (pipeline (yescmd , ` head` , DevNull))
48
50
49
51
begin
50
52
a = Base. Condition ()
51
53
@schedule begin
52
- p = spawn (pipeline (yes ,DevNull))
54
+ p = spawn (pipeline (yescmd ,DevNull))
53
55
Base. notify (a,p)
54
56
@test ! success (p)
55
57
end
84
86
85
87
# STDIN Redirection
86
88
let file = tempname ()
87
- run (pipeline (` $echo hello world` , file))
89
+ run (pipeline (` $echocmd hello world` , file))
88
90
@test readstring (pipeline (file, catcmd)) == " hello world\n "
89
91
@test open (readstring, pipeline (file, catcmd), " r" ) == " hello world\n "
90
92
rm (file)
@@ -104,7 +106,7 @@ if !is_windows() # WINNT reports operation not supported on socket (ENOTSUP) for
104
106
end
105
107
t2 = @async begin
106
108
sock = connect (fetch (r))
107
- run (pipeline (` $echo hello world` , sock))
109
+ run (pipeline (` $echocmd hello world` , sock))
108
110
close (sock)
109
111
return true
110
112
end
@@ -212,7 +214,7 @@ if valgrind_off
212
214
end
213
215
214
216
# issue #6310
215
- @test readstring (pipeline (` $echo "2+2"` , ` $exename --startup-file=no` )) == " 4\n "
217
+ @test readstring (pipeline (` $echocmd "2+2"` , ` $exename --startup-file=no` )) == " 4\n "
216
218
217
219
# issue #5904
218
220
@test run (pipeline (ignorestatus (falsecmd), truecmd)) === nothing
270
272
# issue #10994: libuv can't handle strings containing NUL
271
273
let bad = " bad\0 name"
272
274
@test_throws ArgumentError run (` $bad ` )
273
- @test_throws ArgumentError run (` $echo $bad ` )
274
- @test_throws ArgumentError run (setenv (` $echo hello` , bad=> " good" ))
275
- @test_throws ArgumentError run (setenv (` $echo hello` , " good" => bad))
275
+ @test_throws ArgumentError run (` $echocmd $bad ` )
276
+ @test_throws ArgumentError run (setenv (` $echocmd hello` , bad=> " good" ))
277
+ @test_throws ArgumentError run (setenv (` $echocmd hello` , " good" => bad))
276
278
end
277
279
278
280
# issue #12829
@@ -391,17 +393,17 @@ end
391
393
# equality tests for Cmd
392
394
@test Base. Cmd (` ` ) == Base. Cmd (` ` )
393
395
@test Base. Cmd (` lsof -i :9090` ) == Base. Cmd (` lsof -i :9090` )
394
- @test Base. Cmd (` $echo test` ) == Base. Cmd (` $echo test` )
395
- @test Base. Cmd (` ` ) != Base. Cmd (` $echo test` )
396
+ @test Base. Cmd (` $echocmd test` ) == Base. Cmd (` $echocmd test` )
397
+ @test Base. Cmd (` ` ) != Base. Cmd (` $echocmd test` )
396
398
@test Base. Cmd (` ` , ignorestatus= true ) != Base. Cmd (` ` , ignorestatus= false )
397
399
@test Base. Cmd (` ` , dir= " TESTS" ) != Base. Cmd (` ` , dir= " TEST" )
398
400
@test Base. Set ([` ` , ` ` ]) == Base. Set ([` ` ])
399
- @test Set ([` ` , echo ]) != Set ([` ` , ` ` ])
400
- @test Set ([echo , ` ` , ` ` , echo ]) == Set ([echo , ` ` ])
401
+ @test Set ([` ` , echocmd ]) != Set ([` ` , ` ` ])
402
+ @test Set ([echocmd , ` ` , ` ` , echocmd ]) == Set ([echocmd , ` ` ])
401
403
402
404
# equality tests for AndCmds
403
- @test Base. AndCmds (` $echo abc` , ` $echo def` ) == Base. AndCmds (` $echo abc` , ` $echo def` )
404
- @test Base. AndCmds (` $echo abc` , ` $echo def` ) != Base. AndCmds (` $echo abc` , ` $echo xyz` )
405
+ @test Base. AndCmds (` $echocmd abc` , ` $echocmd def` ) == Base. AndCmds (` $echocmd abc` , ` $echocmd def` )
406
+ @test Base. AndCmds (` $echocmd abc` , ` $echocmd def` ) != Base. AndCmds (` $echocmd abc` , ` $echocmd xyz` )
405
407
406
408
# test for correct error when an empty command is spawned (Issue 19094)
407
409
@test_throws ArgumentError run (Base. Cmd (` ` ))
@@ -411,13 +413,13 @@ end
411
413
412
414
@test_throws ArgumentError spawn (Base. Cmd (` ` ))
413
415
@test_throws ArgumentError spawn (Base. AndCmds (` ` , ` ` ))
414
- @test_throws ArgumentError spawn (Base. AndCmds (` ` , ` $echo test` ))
415
- @test_throws ArgumentError spawn (Base. AndCmds (` $echo test` , ` ` ))
416
+ @test_throws ArgumentError spawn (Base. AndCmds (` ` , ` $echocmd test` ))
417
+ @test_throws ArgumentError spawn (Base. AndCmds (` $echocmd test` , ` ` ))
416
418
417
419
# tests for reducing over collection of Cmd
418
420
@test_throws ArgumentError reduce (& , Base. AbstractCmd[])
419
421
@test_throws ArgumentError reduce (& , Base. Cmd[])
420
- @test reduce (& , [` $echo abc` , ` $echo def` , ` $echo hij` ]) == ` $echo abc` & ` $echo def` & ` $echo hij`
422
+ @test reduce (& , [` $echocmd abc` , ` $echocmd def` , ` $echocmd hij` ]) == ` $echocmd abc` & ` $echocmd def` & ` $echocmd hij`
421
423
422
424
# test for proper handling of FD exhaustion
423
425
if is_unix ()
@@ -453,3 +455,6 @@ let p=Pipe()
453
455
@async close (p. in)
454
456
@test readstring (p. out) == " Int128(0xffffffffffffffffffffffffffffffff)"
455
457
end
458
+
459
+ # readlines(::Cmd), accidentally broken in #20203
460
+ @test sort (readlines (` $lscmd -A` )) == sort (readdir ())
0 commit comments