Frage zur Bash
Ralph Meyer
ralph at schosemail.de
Tue Oct 15 16:47:47 CEST 2013
> > Gibt es einen Unterschied zwischen :
> >
> > --------------------------------------
> > #!/bin/bash
> >
> > if (rpm -q rsyslog &> /dev/null) ; then
> [...]
> > und
> [...]
> > if rpm -q rsyslog &> /dev/null ; then
>
> man bash:
>
> Compound Commands
> A compound command is one of the following:
>
> (list) list is executed in a subshell environment (see COMMAND
> EXECUTION ENVIRONMENT below). Variable assignments and builtin
> commands
> that affect the shell’s environment do not remain in effect
> after the command completes. The return status is the exit
> status of
> list.
>
> Die Befehlsliste in runden Klammern wird in einer Subshell ausgeführt.
> Die Bash startet als Kindprozess eine neue Shell, führt die Befehle darin aus
> und liefert nach Beendigung der Shell den Return Code zurück.
Aha. Also ist lediglich das Starten des Kommandos in einer Subshell der Unterschied.
Also ist der Aufruf ohne Klammern ressourcenschonender, da keine zweite Shell gestartet wird ?
Ralph
More information about the Linux
mailing list