Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: noclobber overzealous with multios and /dev/stdout
- X-seq: zsh-workers 28317
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh workers <zsh-workers@xxxxxxx>
- Subject: Re: noclobber overzealous with multios and /dev/stdout
- Date: Tue, 05 Oct 2010 09:16:11 -0700
- In-reply-to: <AANLkTinyNWKax0n2z+XmoyFOuLOdWkLsujfw86Zw8EQK@xxxxxxxxxxxxxx>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <AANLkTi=PxKX2x5M_oseccYWsSgztpWY_n8Lz9gTu=3vE@xxxxxxxxxxxxxx> <101005080059.ZM4862@xxxxxxxxxxxxxxxxxxxxxx> <AANLkTinyNWKax0n2z+XmoyFOuLOdWkLsujfw86Zw8EQK@xxxxxxxxxxxxxx>
On Oct 5, 5:18pm, Mikael Magnusson wrote:
} Subject: Re: noclobber overzealous with multios and /dev/stdout
}
} On 5 October 2010 17:00, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
} > ... what has happened is that zsh has opened "file" as the standard
} > output (fd 1), which changes the meaning of /dev/stdout and /dev/fd/1
} > to refer to the regular file "file".
}
} > } both 0 and 1 are symlinks to /dev/pts/33
} >
} > No, they aren't. Left-to-right order is important with multios, as
} > it is with descriptor duplication using >&DIGITS.
}
} In case this was unclear, i was referring to /proc/<pid>/fd/0 and 1
} there, they are both symlinks pointing to the same target
} (/dev/pts/33). When i created a symlink in the current dir to the same
} place, i also didn't get the error. Oh, i just realized now, does what
} the symlink in /proc points to change during the evaluation of the
} redirect operators?
Yes!
} I guess they must, in that case i understand what happens :). Ie after
} "> file", /proc/self/fd/1 points to "file", while 0 still points to
} the terminal...
Exactly.
} What i was actually trying to do when i encountered this was use
} multios to write both to the terminal and a file.
You can do that, but you must always name the terminal device first,
or use a device such as /dev/tty that doesn't depend on stdin/stdout.
So
echo test > /dev/stdout > file
should do what you want, or
echo test > file > /dev/tty
if what you really mean is the terminal, rather than the previous
stdout.
} I guess what i must do in that case is first duplicate stdout to a new
} fd with {myfd}>&1 (i always forget the exact syntax for this), and
} then > file >&$myfd ?
That's what you have to do in the absence of multios, e.g. in /bin/sh
(except of course {myfd} doesn't work there, you have to pick a number).
Messages sorted by:
Reverse Date,
Date,
Thread,
Author