Re: inconsistent output for cd
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 According to Tony Balinski on 4/2/2007 9:01 AM: > It seems like this extra output only occurs when CDPATH is used for the > cd operation. Also, popd and pushd also have similarly inconvenient > outputs. None of this is documented in the manual, and there appear to > be no options at all to turn this superfluous output off. This is by design. POSIX requires cd to output the new current directory if CDPATH was used in determining that directory. It is not superfluous output, merely your function needs to take that into account. - -- Don't work too hard, make some time for fun as well! Eric Blake [EMAIL PROTECTED] -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.5 (Cygwin) Comment: Public key at home.comcast.net/~ericblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFGEj1G84KuGfSFAYARAmeiAJkBsz5kNRdr7vTJPlZ852FV0RhsmwCgjLyw a1kWd/JaJOtKMnbEWPZUBKM= =fEFS -END PGP SIGNATURE- ___ Bug-bash mailing list Bug-bash@gnu.org http://lists.gnu.org/mailman/listinfo/bug-bash
Re: inconsistent output for cd
> Bash Version: 3.2 > Patch Level: 15 > Release Status: release > > It seems like this extra output only occurs when CDPATH is used for the > cd operation. Also, popd and pushd also have similarly inconvenient > outputs. None of this is documented in the manual, and there appear to > be no options at all to turn this superfluous output off. This is, as Eric Blake noted, required POSIX behavior. As to the manual: If a non- empty directory name from CDPATH is used, or if - is the first argument, and the directory change is successful, the absolute pathname of the new working directory is written to the standard output. This is from the description of `cd'. `pushd' and `popd' are documented to run the `dirs' builtin upon successful operation, and dirs will print the directory stack. Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer Live Strong. Chet Ramey, ITS, CWRU[EMAIL PROTECTED]http://tiswww.tis.case.edu/~chet/ ___ Bug-bash mailing list Bug-bash@gnu.org http://lists.gnu.org/mailman/listinfo/bug-bash
Re: inconsistent output for cd
On Tue, 3 Apr 2007, Chet Ramey wrote: > > [...] and there appear to > > be no options at all to turn this superfluous output off. > > This is, as Eric Blake noted, required POSIX behavior. As to the manual: It is an interesting position for POSIX to take, given that in general Unix is silent on success. http://www.faqs.org/docs/artu/ch01s06.html#id2878450 Does POSIX forbid an option "to turn this superfluous output off", as Tony Balinski put it? Hugh ___ Bug-bash mailing list Bug-bash@gnu.org http://lists.gnu.org/mailman/listinfo/bug-bash
Re: inconsistent output for cd
> On Tue, 3 Apr 2007, Chet Ramey wrote: > > > > [...] and there appear to > > > be no options at all to turn this superfluous output off. > > > > This is, as Eric Blake noted, required POSIX behavior. As to the manual: > > It is an interesting position for POSIX to take, given that in general > Unix is silent on success. It's the logical thing to do, considering the potential ambiguity that exists when you use a directory selected from CDPATH. The illogical thing is that POSIX requires the output even when the shell is not interactive. > Does POSIX forbid an option "to turn this superfluous output off", as > Tony Balinski put it? Redirect stdout to /dev/null. That's the conventional way to rid yourself of superfluous output. Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer Live Strong. Chet Ramey, ITS, CWRU[EMAIL PROTECTED]http://tiswww.tis.case.edu/~chet/ ___ Bug-bash mailing list Bug-bash@gnu.org http://lists.gnu.org/mailman/listinfo/bug-bash
Re: how does bash parse back-ticks, anyway?
Eric Blake wrote: According to Matthew Woehlke on 4/2/2007 5:09 PM: If nothing else, I'll stand by it being a bash bug, if only in the docs because they are not sufficiently clear. :-) The POSIX rules here are [snip] Ok, but the man page is still unclear. :-) (Sigh. Curse Solaris and their broken /bin/sh that makes it impossible to write portable scripts with $() :-(.) -- Matthew Obscurity: +5 ___ Bug-bash mailing list Bug-bash@gnu.org http://lists.gnu.org/mailman/listinfo/bug-bash
Re: inconsistent output for cd
Quoting Chet Ramey <[EMAIL PROTECTED]>: > > On Tue, 3 Apr 2007, Chet Ramey wrote: > > > > It is an interesting position for POSIX to take, given that in general > > Unix is silent on success. > > It's the logical thing to do, considering the potential ambiguity that > exists when you use a directory selected from CDPATH. The illogical thing > is that POSIX requires the output even when the shell is not interactive. > > > Does POSIX forbid an option "to turn this superfluous output off", as > > Tony Balinski put it? > > Redirect stdout to /dev/null. That's the conventional way to rid yourself > of superfluous output. > This is where I find an inconsistency. With the function I gave, cd () { local oldd=$(pwd); local newd=$(command cd "$@" 2>/dev/null 1>&2 && pwd 2>/dev/null); echo oldd="<$oldd>"; echo newd="<$newd>"; if [[ $newd == "" ]]; then echo "cd $* failed" 1>&2; else if [[ $oldd == $newd ]]; then echo "cd $* - no change" 1>&2; else command cd "$@" 2> /dev/null 1>&2; fi; fi } Running bash on Cygwin (taken from Cygwin): version: GNU bash, version 3.2.15(13)-release (i686-pc-cygwin) Copyright (C) 2005 Free Software Foundation, Inc. the redirection in the assignment of newd for "command cd" doesn't work (when cd generates output). I have a CDPATH=.:/home/tbalinski; now when I use my cd function to go from MiscDocs to Dev (both in /home/tbalinski) I get: $ cd Dev oldd= newd= $ i.e. the newd variable was assigned both the output of cd (which should have gone to /dev/null) and of the pwd that follows it, rather than just the pwd. (I also tried "1>/dev/null 2>&1" for the redirects, same results). Curiously, under the same conditions on a Red Hat Linux box: version: GNU bash, version 2.05b.0(1)-release (i386-redhat-linux-gnu) Copyright (C) 2002 Free Software Foundation, Inc. I get the behaviour I expected: only one line in newd: $ cd Dev oldd= newd= $ Either something strange is going on with the Cygwin compatibility layer or there is a problem with the later bash. Or am I writing my command wrongly? Thanks, Tony ___ Bug-bash mailing list Bug-bash@gnu.org http://lists.gnu.org/mailman/listinfo/bug-bash