2023-09-01 at

(dash) Redirection Operators

Debian Almquist Shell (dash) operators


0.

(dash) is the default (sh) in Debian and Alpine (busybox uses dash).

(bash) is the default (sh) in Red Hat.


1.

Operands are EITHER string filenames (FNs) OR integer file descriptors (FDs); 

this is inflexible.


2.

[ow] "optional whitespace"


3.

"source from LHS (default 1, stdout) ..."


FD>[ow]FN "... sink to RHS, UNenforced clobber"

FD>|[ow]FN "... sink to RHS, enforced clobber"

FD>>[ow]FN "... sink to RHS, append to"

FD>&[ow]FD "... sink to RHS"

FD>&- "... sink to nowhere; (close LHS)"


4.

"sink to LHS (default 0, stdin) ..."


FD<[ow]FN "... source from RHS"

FD<&[ow]FD "... source from RHS"

FD<&- "... source from nowhere; (close LHS)"


FD<<[ow]delimiter "... source is the text between delimiters, 

stuff stuff withOUT parameter expansion"

stuff 

delimiter


FD<<[ow]"delimiter" "... source is the text between delimiters,

stuff stuff with parameter expansion"

stuff

delimiter


... furthermore if (<<) is replaced with (<<-), 

then leading tabs in the here-doc-text are stripped.


5.

"open on LHS (default 0, stdin) ..." 


FD<>[ow]FN "... for both reading and writing to RHS, UNenforced clobber"


6.

These are not implemented; you can't use these in (dash).


&>[ow]FN "(bash/zsh) for ( 1>[ow]FN 2>&1 ): 

both 2 and 1 end up in FN, UNenforced clobber"

&>>[ow]FN "(bash/zsh) for ( 1>>[ow]FN 2>&1 ): 

both 2 and 1 end up in FN, append to"

>>&[ow]FN "(zsh) for ( &>>[ow]FN ); not implemented in (bash)"

No comments :

Post a Comment