Sample Header Ad - 728x90

bash conditional variable assignment cli not what I expected

0 votes
1 answer
47 views
Can anyone explain what's going on with DR here?
user@host:~# DRYRUN=true
user@host:~# echo "$DRYRUN"
true
user@host:~# $DRYRUN && export DR="-n"
user@host:~# echo $DR
user@host:~# $DRYRUN && export DR="-n" && echo $DR
user@host:~# $DRYRUN && export DR="-n" && echo "$DRYRUN --- $DR"
true --- -n
user@host:~# echo $DR
user@host:~# echo "$DRYRUN --- $DR"
true --- -n
user@host:~#
I Just want to assign DR to the string "-n" when DRYRUN is set to true but what I'm getting is confusing
Asked by Hugh (19 rep)
May 12, 2025, 03:04 PM
Last activity: May 12, 2025, 03:43 PM