On Sun 11 Feb 2024 at 09:16:00 (-0600), David Wright wrote: > On Sun 11 Feb 2024 at 09:54:24 (-0500), Greg Wooledge wrote: > > On Sun, Feb 11, 2024 at 03:45:21PM +0100, to...@tuxteam.de wrote: > > > Still there's the discrepancy between doc and behaviour. > > > > There isn't. The documentation says: > > > > SYNOPSIS > > shred [OPTION]... FILE... > > > > DESCRIPTION > > Overwrite the specified FILE(s) repeatedly, in order to make it > > harder > > for even very expensive hardware probing to recover the data. > > > > If FILE is -, shred standard output. > > > > In every sentence, the word FILE appears. There's nothing in there > > which says "you can operate on a non-file". > > > > Once you grasp what the command is *intended* to do (rewind and overwrite > > a file repeatedly), it makes absolutely perfect sense that it should > > only operate on rewindable file system objects. > > > > If you want it to write a stream of data instead of performing its normal > > operation (rewinding and rewriting), that's a new feature. > > > > If you'd prefer the documentation to say explicitly "only regular files > > and block devices are allowed", that would be an upstream documentation > > *clarification* request. > > Perhaps info puts it better?
… but not much. For me, "standard output" is /dev/fd/1, yet it seems unlikely that anyone is going to use >&1 in the manner of the example. I might write something like: "The option ‘-’ shreds the file specified by the redirection ‘>&N’", though there could be a better name for ‘>&N’. > A FILE of ‘-’ denotes standard output. The intended use of this is > to shred a removed temporary file. For example: > > i=$(mktemp) > exec 3<>"$i" > rm -- "$i" > echo "Hello, world" >&3 > shred - >&3 > exec 3>- I can see that the last line truncates the "anonymous" file, but where is that construction documented¹, and how would one parse the syntax elements FD > - to make them mean truncate? > However, the command ‘shred - >file’ does not shred the contents of > FILE, since the shell truncates FILE before invoking ‘shred’. Use > the command ‘shred file’ or (if using a Bourne-compatible shell) the > command ‘shred - 1<>file’ instead. ¹ the string ">-" doesn't appear in /usr/share/doc/bash/bashref.pdf, ver 5.1, for example. Cheers, David.