NetBSD-Bugs archive

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

Re: bin/48843: sh(1): break/continue/return broken inside dot commands



The following reply was made to PR bin/48843; it has been noted by GNATS.

From: Jarmo Jaakkola <jarmo.jaakkola%roskakori.fi@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc: 
Subject: Re: bin/48843: sh(1): break/continue/return broken inside dot
        commands
Date: Sun, 1 Jun 2014 19:25:21 +0300

 Soften the language in the manual page, making less promises about
 behavior not explicitly stated in the standard.
 
 
 diff -u orig/sh.1 new/sh.1
 --- orig/sh.1
 +++ new/sh.1
 @@ -1193,9 +1193,10 @@ variable if it does not contain a directory separator
  .Pq Sq / .
  The return command can be used for a premature return from the sourced file.
  .Pp
 -A non-obvious consequence of the file executing in the current environment
 -is that loop control keywords (continue and break) can be used in the file
 -to control loops surrounding the dot command.
 +The POSIX standard is unclear on how loop control keywords (break
 +and continue) behave across a dot command boundary.
 +This implementation allows them to control loops surrounding the dot command,
 +but obviously such behavior should not be relied on.
  .It alias Op Ar name Ns Op Ar "=string ..."
  If
  .Ar name=string
 @@ -1641,11 +1642,13 @@ For portability,
  .Ar n
  should be in the range from 0 to 255.
  .Pp
 -The effects of using a return command outside a function or a dot command
 -are not standardized.
 -This implementation (currently) treats such a return as a no-op with
 -a return value of 0 (success, true).
 -Use the exit command if you want to return from a script or exit your shell.
 +The POSIX standard says that the results of
 +.Sq return
 +outside a function or a dot command are unspecified.
 +This implementation treats such a return as a no-op with a return value of 0
 +(success, true).
 +Use the exit command instead, if you want to return from a script or exit
 +your shell.
  .It set Oo { Fl options | Cm +options | Cm \-- } Oc Ar arg ...
  The
  .Ic set
 
 
 -- 
 Jarmo Jaakkola
 


Home | Main Index | Thread Index | Old Index