On Tuesday 30 December 2008 15:00:18 Eric Blake wrote: > According to Pádraig Brady on 12/30/2008 2:46 AM: > >> Usage: truncate [OPTION]... [FILE]... > > > > Is supporting stdin a useful enhancement? er ... > > Maybe if you can get the shell to open > > different files based on some condition, > > though again that seems a little contrived. > > if cond ; then > foo=file1 > else > foo=file2 > fi > truncate -s0 <$foo This redirection is wonderful, but entirely counter-intuitive. By convention stdout is where writes occur, stdin is where reads occur. Modifying the file given as stdin is just a little unexpected.
For good measure (all?) shells open stdin as read-only, which makes the operation fail -- ftruncate(0,0) gives "invalid argument". The redirection you need for a writable stdin under bash seems to be this one: truncate -s$SIZE 0>>$foo &:-) _______________________________________________ Bug-coreutils mailing list Bug-coreutils@gnu.org http://lists.gnu.org/mailman/listinfo/bug-coreutils