Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 28 May 1997 16:50:23 +0200 (MET DST)
From:      Zahemszky Gabor <zgabor@CoDe.hu>
To:        freebsd-questions@freebsd.org (FreeBSD questions)
Cc:        un_x@anchorage.net
Subject:   Re: What command line to redirect 'make world' warnings ?
Message-ID:  <199705281450.QAA00425@CoDe.hu>
In-Reply-To: <Pine.BSF.3.95q.970527173802.1668B-100000@aak.anchorage.net> from Steve Howe at "May 27, 97 06:46:10 pm"

next in thread | previous in thread | raw e-mail | index | archive | help
Well, I've written RTMF, because he/she(?) wrote "in bash ..." - so maybe
(s)he HAS bash - and bash manual, too.

> > > 	make world 2>&1 > /proxy/world3
> 
> stdout to tty
> stderr to tty
> redirection 2>&1
> stderr to stdout (tty)
> redirection > file
> stdout to file
> 
> got it!  i think this is an easy mistake to make, since one would assume
> if a stderr is duplicated on stdout, then any redirection of stdout would
> also apply to stderr.

After duplication - I think - they go paralell, but not on the same way.  If
one of them turn, the other needn't.

> got it.  i notice "make world > 2>&1 /proxy/world3" is an error,
> but               "make world 2>&1 > /proxy/world3" is not! (sh)

Of course, because the ">" needs a parameter (a filename or a &foo
construct), but there isn't any.

> > 	      &>word
> >        and
> > 	      >&word
> > 
> >       Of  the two forms, the first is preferred.
> >	This is semantically equivalent to
> >
> > 	      >word 2>&1
> > 
> > This type of redirection is working only in bash ...
> 
> so with bash one could say:
> 
> make world 2&>1 /proxy/world3
> 
> and get the desired effect, correct? (i don't have bash ...)

No!  you have to type
make world &> /proxy/world3
and it's the same as the original
command >file 2>&1 
form.  As I understood from the bash manual.

(Well, I didn't try your version.  Maybe I'll have more time some times
later.)

> > ( make world 2>&1 >> /proxy/world3 ) > /proxy/world3
> 
> in a subshell:
> stdout to tty
> stderr to tty
> redirection 2>&1
> stderr to stdout
> stdout >> file
> end subshell.
> --------------
> redirection > file
> stdout (subshell stderr) > file
> 
> got it!
> 
> > { make world 2>&1 >> /proxy/world3 ; } > /proxy/world3
> 
> same thing with grouping instead of subshell spawning.
> 
> > and you have to use append ( >> ) inside.  Well, why?  It's your exercise.
> 
> hmmm.  in sh, ">" inside works as well ... ???

Really?  If it is, I think, it's a bug in shell, because first, we make the
redirection in the parent shell, after in the sub shell.  But in the subshell,
with ">", we reopen it with truncation, but with ">>", with append only.
Well, I've tried it with 2.1.5's sh, with pdksh 5.2.12 and with bash 1.14.5,
and worked as I wrote.  I think, in your example, you hadn't got an error
message.  Try this one:
$ echo lo > file
$ ( cat nosuchfile lo 2>&1 > f ) > f ; cat f
lo
$ ( cat nosuchfile lo 2>&1 > f ) > f ; cat f
cat: nosuchfile: No such file or directory
lo
$

Well, I think maybe it's some undocumented behaviour of not a bug/not a
feature of the buffering of shell.???

Bye, Gabor

-- 
#!/bin/ksh
Z='21N16I25C25E30, 40M30E33E25T15U!' ;IFS=' ABCDEFGHIJKLMNOPQRSTUVWXYZ ';set $Z;for i { [[ $i = ? ]]&&print $i&&break;[[ $i = ??? ]]&&j=$i&&i=${i%?};typeset -i40 i=8#$i;print -n ${i#???};[[ "$j" = ??? ]]&&print -n "${j#??} "&&j=;typeset +i i;};IFS=' 0123456789 ';set $Z;X=;for i { [[ $i = , ]]&&i=2;[[ $i = ?? ]]||typeset -l i;X="$X $i";typeset +l i;};print "$X"



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199705281450.QAA00425>