I stopped looking).
Perhaps documenting the behavior would be helpful. Maybe the last sentence
to the declare help could say, "Attributes added with -a or -A do not take
effect until subsequent assignments."
Peggy Russell
Release 4.3.0(1)-rc2
The help for "case", in the shell's builtin command "help", shows the
operator ;; but not the operators ;& and ;;&.
help case
Peg Russell
> I noticed that bash is in absolute minority of projects not using any
> bug reporting system. Instead, users are directed to this ML to report bugs.
Also see: man bashbug
Maybe an RSS feed could help, like:
http://rss.gmane.org/gmane.comp.shells.bash.bugs
Peggy Russell
p var
3) declare -i var1= var2; declare -p ${!var*}
where the option 'i' above could be 'iaAnr' (1)(2)(3) and with the
additional '-' in (2)(3).
Peggy Russell
provide a supportive argument, maybe, for your suggestion
option #1. http://mywiki.wooledge.org/Quotes is helpful.
Peggy Russell
t
isn't failing at all. Declaring a global variable that already exists as a
globally scoped variable is a no-op, and in a function declaring a global
variable that already exists as a locally scoped variable, bash uses the
locally scoped variable.
Thank you.
Peggy Russell
;data2"
3 test_error: rc [0] <===
./zt: line 18: declare: var: not found <===
declare -- var="data3"
== test_error: []
===
Peggy Russell
GN-*"
Greg added the quotes. Thanks.
I tested with:
mkdir "dir with spaces"
touch "dir with spaces"/simple-{a..c} "dir with spaces"/test-abc-IGN-def "dir
with spaces/spa ces"
./scriptname "dir with spaces"
Worked as expected.
Peggy Russell
nd such?
A variation:
shopt -s nullglob
for f in ${1:-.}/*; do
if [[ "${f}" != *-IGN-* ]];
then printf -- '%s\n' "${f}"
fi
done
Peggy Russell
> For straight debugging output, it's probably ok. You might have to
> play with it a little if you want to make it into something you can
> eval from a command substitution to copy an array.
Just another thought,
declare -p aa
is nice for debugging arrays.
help declare
...
-pdisplay t
ontents of r which was 0
[[ $? -eq $r ]] + [[ 0 -eq 0 ]]
[[ $? -eq ${r:=0} ]]+ [[ 0 -eq 0 ]]
For a user to see/trace r, they would either echo/printf, declare -p r,
or refer to it as $r (displayed by set -x).
Can users see more trace info on what happens within [[ (i.e.; [['s value for
r)?
Thank you.
Peggy Russell
f [[ $? -eq $r ]]; then echo "4 Y"; else echo "N";fi
...
+ [[ 0 -eq 0 ]]
+ echo '4 Y'
(Similar to 3)
unset r a; a=0; declare -i r=a
/bin/true; if [[ $? -eq r ]]; then echo "5 Y"; else echo "N";fi
...
+ [[ 0 -eq r ]] <-
+ echo '2 Y'
Thank you.
Peggy Russell
> The existing documentation seems pretty clear:
> ...
> The value of a variable is evaluated as an arithmetic expression when
> it is referenced, or when a variable which has been given the integer
> attribute using declare -i is assigned a value. A null value evaluates
> to 0. A shell var
> Since those are not numeric, bash treats them as expressions to be
> evaluated. You don't have to use the $ to obtain variable evaluation
> when using [[ or [. You get:
c=1;a="c";b=2;[[ a -lt b ]]; echo $?
0
c=3;a="c";b=2;[[ a -lt b ]]; echo $?
1
I see. I was aware of explicit indirection as
an error occurs.
* EXIT_SUCCESS = 0
* EXIT_FAILURE = non-zero value
- When using compound commands, the exit status of 0 and
nonzero still stands, but there is an intermediary step
that deals with how conditional and arithmetic expressions
are evaluated.
- Arithmetic Evaluation ((...)): Within an expression, shell
variables may be referenced by name without using the
parameter expansion syntax.
=
Thank you.
Peggy Russell
15 matches
Mail list logo