Frage zur Bash

Frank Bergmann tx-7-12 at tuxad.com
Tue Oct 15 16:23:28 CEST 2013


On Tue, Oct 15, 2013 at 03:35:10PM +0200, Ralph Meyer wrote:
[...]
> 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.


-- 
EDV Frank Bergmann                           Tel.     05221-9249753
LPIC-3 Linux Professional                    Fax      05221-9249754
Pödinghauser Str. 5                          email    tx2013 at tuxad.de
32051 Herford                                USt-IdNr DE237314606



More information about the Linux mailing list