On 08/08/2018 at 08:08, J. Fahrner wrote: > Am 2018-08-08 02:42, schrieb Steve Litt: >> ====================================== >> #!/bin/sh >> exec 2>&1 >> exec unbound -p -dd >> ====================================== > > Can you explain this strange construct? An exec without a command but > with i/o redirection? Normally a script ends at the first exec. > > Why not simply > > exec unbound -p -dd 2>&1 ? > > Jochen
Please read bash(1), section "SHELL BUILTIN COMMANDS": exec [-cl] [-a name] [command [arguments]] If command is specified, it replaces the shell. No new process is created. The arguments become the arguments to command. If the -l option is supplied, the shell places a dash at the begin- ning of the zeroth argument passed to command. This is what login(1) does. The -c option causes command to be executed with an empty environment. If -a is supplied, the shell passes name as the zeroth argument to the executed command. If command can- not be executed for some reason, a non-interactive shell exits, unless the execfail shell option is enabled. In that case, it returns failure. An interactive shell returns failure if the file cannot be executed. If command is not specified, any redi- rections take effect in the current shell, and the return status is 0. If there is a redirection error, the return status is 1. I quote again just the part that is relevant to the case ah hand: "If command is not specified, any redi- rections take effect in the current shell, and the return status is 0. If there is a redirection error, the return status is 1." Try this, to see what is the effect of this execution of exec: [alessandro@wkstn03]$ exec 3> /tmp/fd3 [alessandro@wkstn03]$ ls >&3 [alessandro@wkstn03]$ cat /tmp/fd3 Enjoy! Unix, the OS that still has some new trick on the basic commands after you've been using it for 20+ years! -- Alessandro Selli <alessandrose...@linux.com> Tel. 3701355486 VOIP SIP: dhatarat...@ekiga.net Chiave firma e cifratura PGP/GPG signing and encoding key: BA651E4050DDFC31E17384BABCE7BD1A1B0DF2AE
signature.asc
Description: OpenPGP digital signature
_______________________________________________ Dng mailing list Dng@lists.dyne.org https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng