fork download
  1. #!/bin/bash
  2.  
  3.  
  4. # ideone boilerplate: run in temp dir
  5. t=$(mktemp -d -t ideone.XXXXXXXX) || exit
  6. # trap 'rm -rf "$t"' ERR EXIT
  7. cd "$t"
  8.  
  9. touch one\ file two\ files unquoted\ \*
  10. mkdir zzz
  11.  
  12. ls -l >&2
  13.  
  14. for [ z in `echo *` ]; do
  15. echo "$z"
  16. done
  17.  
  18. if [ test -d $z ]; then
  19. echo "$z is a directory"
  20. fi
  21.  
  22. trap 'rm -rf "$t"' ERR EXIT
  23. exec >&2
  24.  
  25. echo ... You probably meant
  26.  
  27. for z in *; do
  28. echo "$z"
  29. done
  30. # ... or better yet
  31. printf '%s\n' *
  32.  
  33. if [ -d "$z" ]; then
  34. echo "$z is a directory"
  35. fi
Runtime error #stdin #stdout #stderr 0s 4872KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
total 0
-rw-rw-r-- 1 20091 1000  0 Dec 17 16:43 one file
-rw-rw-r-- 1 20091 1000  0 Dec 17 16:43 two files
-rw-rw-r-- 1 20091 1000  0 Dec 17 16:43 unquoted *
drwxrwxr-x 2 20091 1000 40 Dec 17 16:43 zzz
./prog.sh: line 14: syntax error near unexpected token `z'
./prog.sh: line 14: `for [ z in `echo *` ]; do'