tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: bin/39466: /bin/sh: eval and redirections



Exit status of eval with bad redirection

   ~>bash -c 'eval "cat > /path/to/file"; echo $?' 
   bash: line 1: /path/to/file: No such file or directory
   1
   ~>zsh -c 'eval "cat > /path/to/file"; echo $?'  
   zsh: no such file or directory: /path/to/file
   1
   ~>ksh -c 'eval "cat > /path/to/file"; echo $?' 
   ksh: cannot create /path/to/file: No such file or directory
   1
   ~>zsh -c 'eval "cat > /path/to/file"; echo $?' 
   zsh: no such file or directory: /path/to/file
   1
   ~>mksh -c 'eval "cat > /path/to/file"; echo $?'
   mksh: cannot create /path/to/file: No such file or directory
   1
   ~>dash -c 'eval "cat > /path/to/file"; echo $?'     
   eval: 1: cannot create /path/to/file: Directory nonexistent
   2
   ~>/usr/pkg/heirloom/bin/sh -c 'eval "cat > /path/to/fi> 
   /usr/pkg/heirloom/bin/sh: /path/to/file: cannot create
   1
   ~>/bin/sh -c 'eval "cat > /path/to/file"; echo $?'
   eval: cannot create /path/to/file: directory nonexistent
=> 0
   ~>


And 'set -e' too

   0 ~>/usr/pkg/heirloom/bin/sh /home/cheusov/tmp/1.sh 
   /home/cheusov/tmp/1.sh: /path/to/bad/file.txt: cannot create
   1 ~>/bin/ksh /home/cheusov/tmp/1.sh                 
   /home/cheusov/tmp/1.sh: cannot create /path/to/bad/file.txt: No such file or 
directory
   1 ~>mksh /home/cheusov/tmp/1.sh                     
   /home/cheusov/tmp/1.sh: cannot create /path/to/bad/file.txt: No such file or 
directory
   1 ~>dash /home/cheusov/tmp/1.sh                     
   eval: 1: cannot create /path/to/bad/file.txt: Directory nonexistent
   2 ~>zsh /home/cheusov/tmp/1.sh                      
   (eval):1: no such file or directory: /path/to/bad/file.txt
   1 ~>bash /home/cheusov/tmp/1.sh                     
   /home/cheusov/tmp/1.sh: line 1: /path/to/bad/file.txt: No such file or 
directory
   1 ~>/bin/sh /home/cheusov/tmp/1.sh                  
   eval: cannot create /path/to/bad/file.txt: directory nonexistent
=> This should not happen!
=> 0 ~>cat /home/cheusov/tmp/1.sh                           
   #!/bin/sh

   set -e

   eval 'cat > /path/to/bad/file.txt'

   echo "This should not happen!"
   0 ~>

-- 
Best regards, Aleksey Cheusov.


Home | Main Index | Thread Index | Old Index