help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-bash] "local" modifies the behavior of "$?"


From: Peng Yu
Subject: [Help-bash] "local" modifies the behavior of "$?"
Date: Sun, 23 Jun 2013 17:43:26 -0500

Hi,

The following code the difference between an local variable assignment
and non local variable assignment wrt to "$?". Is this documented?
Should the result be consistent between the two scenarios? Thanks.

~/linux/test/bash/man/shell_grammar/simple_commands/=$ cat main1.sh
#!/usr/bin/env bash

function cmd {
local str=$(readlink -f -e xxxx)
echo $?
}
cmd

str=$(readlink -f -e xxxx)
echo $?
readlink -f -e xxxx
echo $?

~/linux/test/bash/man/shell_grammar/simple_commands/=$ ./main1.sh
0
1
1

-- 
Regards,
Peng



reply via email to

[Prev in Thread] Current Thread [Next in Thread]