[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Set verbose Flag Inside if-block
From: |
Sysadmin Lists |
Subject: |
Set verbose Flag Inside if-block |
Date: |
Sun, 16 Apr 2023 04:54:41 +0200 (CEST) |
What explains the difference here? Why does setting verbose inside the
if-statement not echo the command, but setting x does, and setting verbose
before the if-statement does, too?
$ if true; then set -ve; echo $-; echo foo bar baz; set -ve; fi
ehimvBHs
foo bar baz
$ set -ve; if true; then echo $-; echo foo bar baz; set -ve; fi
set -ve; if true; then echo $-; echo foo bar baz; set -ve; fi
ehimvBHs
foo bar baz
$ if true; then set -xe; echo $-; echo foo bar baz; set -xe; fi
+ echo ehimvxBHs
ehimvxBHs
+ echo foo bar baz
foo bar baz
+ set -xe
$ set -xe; if true; then echo $-; echo foo bar baz; set -xe; fi
set -xe; if true; then echo $-; echo foo bar baz; set -xe; fi
+ set -xe
+ true
+ echo ehimvxBHs
ehimvxBHs
+ echo foo bar baz
foo bar baz
+ set -xe
--
Sent with https://mailfence.com
Secure and private email
Re: Set verbose Flag Inside if-block, Sysadmin Lists, 2023/04/17