On Wed, Jul 23, 2014 at 1:29 PM, Chet Ramey chet.ra...@case.edu wrote:
On 7/23/14, 3:20 AM, maik.lied...@sungard.com wrote:
hello,
to change our scripts from ksh to bash we have problems with vars and
leading zeros.
how we can declare hrs and min?
Greg offered several good suggestions to
the very first difference I've ever noticed in zsh between bash
and ksh emulations.)
--
Dan Douglas
On Wednesday, July 23, 2014 05:44:25 PM Dan Douglas wrote:
On Wednesday, July 23, 2014 05:02:42 PM Chet Ramey wrote:
ksh93 -c 'echo $(( 010 ))'
Oh heh. Maybe a compile-time option or something I'm doing wrong... I always
assumed it intentionally violates POSIX.
I also just noticed zsh
from a function with a RETURN trap set
bypasses the trap if break results in jumping out of the function (Yes, I
tried that one long ago).
--
Dan Douglas
On Sunday, July 06, 2014 10:04:17 AM Dan Douglas wrote:
Frustratingly I'm pretty sure there isn't even a possible hackish eval or
alias workaround.
Haha nevermind. I guess Bash in non-POSIX mode expands an aliased done
keyword.
shopt -s expand_aliases
alias done='done; (exit $_status
I've heard process substitutions considerably complicate parsing. zsh
and ksh93 are the only others that have process substitutions that I
know of, and zsh can't handle unbalanced parentheses in that situation
either.
$ zsh -c $'cat (cat EOF\n(test)(foo\nEOF\n)'
zsh:4: parse error near `(cat
On Wed, Jun 18, 2014 at 2:49 PM, Chet Ramey chet.ra...@case.edu wrote:
Yes, since bash can parse the same construct without any problems if you
use command substitution, it looks like a bug. I'll take a look.
It brings to mind all those unbalanced paren case..esac bugs that
affected every
On Tue, Jun 10, 2014 at 8:39 AM, Dale R. Worley wor...@alum.mit.edu wrote:
From: Dan Douglas orm...@gmail.com
On Mon, Jun 9, 2014 at 7:51 PM, Dale R. Worley wor...@alum.mit.edu wrote:
But if I add braces around the condition, 'time' is recognized:
That's not too surprising
On Mon, Jun 9, 2014 at 7:51 PM, Dale R. Worley wor...@alum.mit.edu wrote:
But if I add braces around the condition, 'time' is recognized:
That's not too surprising. That ! is unaffected is. if ! ! time :;
then ... is an equivalent but working pipeline. if time { :; };
should also be valid but
of file' unexpected
--
Dan Douglas
with Guido, as do many others. Though all the same arguments apply
in this case. I see no good reason for an arbitrary limit but I understand the
opposing view.
--
Dan Douglas
.
Glad it's not arbitrarily capped at 1k.
$ time dash -c 'f() { echo $1; f $(($1 + 1)); }; f 0' | tail -n 1
13776
real0m0.035s
user0m0.020s
sys 0m0.033s
$ time bash -c 'f() { echo $1; f $(($1 + 1)); }; f 0' | tail -n 1
8308
real0m3.993s
user0m4.032s
sys 0m0.165s
--
Dan
/syntax/expansion/brace#more_fun
--
Dan Douglas
20140517
20140518 20140519
--
Dan Douglas
On Saturday, May 10, 2014 03:31:05 PM Dan Douglas wrote:
$ bash -c 'printf -v a %(%s)T -1; printf %(%Y%m%d)T $a
${a[a+=60*60*24,0]{0..8}}; echo'
20140510 20140511 20140512 20140513 20140514 20140515 20140516 20140517
20140518 20140519
By the way, I'm not very good at remembering
; }
function h { typeset -n ref=$1; echo ${ref-unset}; }
f x # should print unset
--
Dan Douglas
'
declare -- _; y=foo
++ typeset -p '_; y'
+ eval 'declare -- _; y=foo'
++ declare -- _
++ y=foo
+ echo foo
foo
--
Dan Douglas
#21 0x0041f6ee in run_one_command (command=0x7fffd5fe function f {
typeset x; typeset -n x; x=y; }; f) at shell.c:1339
#22 0x0041e9e0 in main (argc=3, argv=0x7fffd108,
env=0x7fffd128) at shell.c:694
--
Dan Douglas
On Wednesday, May 07, 2014 10:04:11 AM Chet Ramey wrote:
On 5/7/14, 2:10 AM, Dan Douglas wrote:
By doesn't shadow you mean that it _does_ hide the global right?
Localizing
a variable should cover up globals and variables in parent scopes even if
they
aren't given a value. That seems
On Wednesday, May 07, 2014 10:58:42 AM Chet Ramey wrote:
On 5/7/14, 10:21 AM, Dan Douglas wrote:
Another one to do with namerefs. :-)
Looks like it's when the target of the ref is local to the same scope.
$ gdb -q -ex 'run -c function f { typeset x; typeset -n x; x=y; }; f'
./bash
be missed. Worked out
fine for ECMAScript5 strict.)
--
Dan Douglas
On Monday, May 05, 2014 09:37:27 AM Eric Blake wrote:
On 05/05/2014 05:09 AM, Dan Douglas wrote:
Just a heads up on something I hadn't noticed: Bash (and dash) treat
octal literals in printf precision inconsistently (using glibc -- not
sure if it's a bug or GNUism on that end or the shell
differences that don't have
to do with exporting.
Test 1 exports a global then localizes it. Test 2 exports a local and
tests a local from a child scope. Test 3 tests exported namerefs.
--
Dan Douglas
Not sure we have enough info here. Have you tried set -x to see what's really
going on? Have you also confirmed that it isn't actually calling your script
and the script simply isn't functioning as expected?
--
Dan Douglas
)
+ dequote '; evil'
+ eval printf %s '; evil'
evil here
--
Dan Douglas
'%.3Ls\n' $'\u2605\u2605\u2605\u2605\u2605'
★
Also, zsh does this by default with no special option. I tend to lean towards
going by character anyway because that's what most shell features such as read
-N do, and most work directly involving the shell is with text not binary data.
--
Dan
and the -A would be very useful even if left undocumented or marked as
deprecated.
--
Dan Douglas
On Thu, Mar 27, 2014 at 3:16 AM, Dan Douglas orm...@gmail.com wrote:
I have such a function of course, but don't care to make every script depend
on it.
Oh, and of course I'll still be using the wrapper. This is a feature for my
great grandchildren to use once Apple is out of business
I don't believe any shell can currently read nul-delimited input into
an array without looping. It's been suggested to add a delimiter to
mapfile. It looks like mapfile uses zgetline() to wrap around calls to
zread() and doesn't support any delimiter. read(1) on the other hand
uses one of the
On Thu, Mar 27, 2014 at 5:05 PM, Mike Frysinger vap...@gentoo.org wrote:
thanks, i wasn't aware of that func. that seems like the easiest solution.
mapfile it awesome, but for getting find(1) results into an array you
should continue to use a read -rd '' loop. read -d is somewhat
portable, and
it exists isn't clear.
There are other alternate syntaxes that are also discouraged, but undocumented,
such as the for ((;;)) { ...; } syntax.
--
Dan Douglas
On Fri, Mar 7, 2014 at 1:38 PM, Eduardo A. Bustamante López
dual...@gmail.com wrote:
WARNING: the codes given below cause the shell to enter an infinite
loop.
Both:
dualbus@debian:~$ bash -Tc 'f(){ :; }; trap return RETURN; f'
^C
and:
dualbus@debian:~$ bash -c 'f(){ trap return RETURN;
On Fri, Jan 17, 2014 at 8:07 AM, Greg Wooledge wool...@eeg.ccf.org wrote:
On Fri, Jan 17, 2014 at 08:53:07AM -0500, Chet Ramey wrote:
On 1/17/14 8:01 AM, Greg Wooledge wrote:
I would expect [[ x =~ yx ]] to fail (return 1) every time.
There is a question about the correct behavior when y ==
On Saturday, April 06, 2013 03:48:55 AM Dan Douglas wrote:
Bash (4.2.45) uniquely does interpret such escapes for [[, which makes me
think this test should say no:
x=\\x; if [[ x == $x ]]; then echo yes; else echo no; fi
Here's more data. Some permutations of escaped and quoted
a strong
desire for this. A good editor should make normal comments painless enough.
--
Dan Douglas
-o and -a are for entertainment.
~ $ bash -c 'set -a; [ -o -a -o -a -o ]; echo $?'
1
~ $ mksh -c 'set -a; [ -o -a -o -a -o ]; echo $?'
0
~ $ bash -c '[ -o -a -o -a -o -o ]; echo $?'
0
~ $ mksh -c 'o=1 [ -o -a -o -a -gt -o ]; echo $?'
0
--
Dan Douglas
-fun-with-IFS-td11388.html
The assignments are all consistent in 4.3.
https://gist.github.com/ormaaj/6381747
--
Dan Douglas
before the LHS of the +=.
There's just no amount of mind-bending I can think of that could make
evaluating the += first produce anything other than an error.
--
Dan Douglas
--
Dan Douglas
'
[-Wunsequenced]
int main() { int x=0; printf(%d\n, x+=x=1); return 0; }
~~ ^
1 warning generated.
2
--
Dan Douglas
On Sunday, August 04, 2013 12:30:48 AM Roland Mainz wrote:
On Sun, Aug 4, 2013 at 12:04 AM, Dan Douglas orm...@gmail.com wrote:
Is it specified what the value of x should be after this expression?
x=0; : $((x+=x=1))
Bash, ksh93, mksh, posh say 1. zsh, dash, busybox say 2. Clang and gcc
in any shell provided
# you can supply all the necessary workarounds, and they correctly interpret
# ksh93 printf %q output (requires $'...'). At least one level of recursive
# arithmetic variable evaluation must also be supported.
# Dan Douglas orm...@gmail.com
namespace main {
# e.g. add set
with another modifier expands arrays to a single
word.
fixed.
:-)
--
Dan Douglas
evaluating to whatever expression is stored in x.
If you want, you can force it to behave the other way as shown in my first
reply.
The primary reason I said it isn't a bug is because this has been discussed on
the list a few times before and that's been the general consensus.
--
Dan Douglas
, and doesn't have to do with the
order options are supplied in.
--
Dan Douglas
I even have some code that relies upon this effect.
--
Dan Douglas
that by using read:
read _CRST (tput sgr0) #Reset
read _CRed (tput setaf 1) #Red
read _CBLD (tput bold) #Bold
Can also give all the debug output %q formatting.
exec {BASH_XTRACEFD} (set +x; while IFS= read -r x; do printf %q\\n $x;
done)
--
Dan Douglas
This function (colorSet) takes one or more associative array names and
can populate it with a few predefined color palates. Written for
Bash/ksh93/zsh.
http://wiki.bash-hackers.org/snipplets/add_color_to_your_scripts
--
Dan Douglas
On Thu, Jun 20, 2013 at 7:09 AM, Greg Wooledge wool...@eeg.ccf.org wrote:
On Wed, Jun 19, 2013 at 06:12:57PM -0500, Dan Douglas wrote:
Thanks to mksh, posh, etc not supporting POSIX character classes at all, I'm
not so sure it's actually better in practice. (talking about standard shell
it defined for the POSIX locale.
Thanks to mksh, posh, etc not supporting POSIX character classes at all, I'm
not so sure it's actually better in practice. (talking about standard shell
pattern matching of course)
--
Dan Douglas
printf '%s ' ${!1}
echo
}
a=( '(a b c)' $'([3]=\'(d e f)\' [5]=1 2 3)' '(g h i)' )
# typeset -a a=(([0]=a [1]=b [2]=c) ([3]=([0]=d [1]=e [2]=f) [5]=1 [6]=2 [7]=3)
([0]=g [1]=h [2]=i) )
getElem 'a[1][3][@]' || echo unset
--
Dan Douglas
.
To validate a parameter name fully requires a full shell parser, because the
subscript of an indexed array is effectively a part of its name as far as Bash
is concerned.
--
Dan Douglas
On Friday, June 14, 2013 06:02:15 AM Dan Douglas wrote:
On Monday, June 10, 2013 09:39:56 AM Greg Wooledge wrote:
On 10 Jun 2013 14:15, Chris F.A. Johnson ch...@cfajohnson.com wrote:
It is not the least bit difficult with eval:
eval array=( \\${$1[@]}\ )
On Mon, Jun 10
On Friday, June 14, 2013 02:30:19 PM Pierre Gaston wrote:
On Fri, Jun 14, 2013 at 2:25 PM, Dan Douglas orm...@gmail.com wrote:
Also forgot to mention (though it should be obvious).
$ ~/doc/programs/bash43 -c 'function f { typeset -n x=$1; : $x; }; a=(yo
jo); f a[\$(echo yes this even
find it. Ignore if so.
--
Dan Douglas
.
--
Dan Douglas
mode
--
Dan Douglas
://mywiki.wooledge.org/ProcessManagement
http://mywiki.wooledge.org/SignalTrap
--
Dan Douglas
0m0.000s
real0m0.000s
user0m0.000s
sys 0m0.000s
As an aside, don't store commands in variables.
http://mywiki.wooledge.org/BashFAQ/050
--
Dan Douglas
no, dash says yes
19:33:40 jilles: Bourne shell says no
--
Dan Douglas
is the
default binary name produced by the heirloom build, though I've seen other
names used.
--
Dan Douglas
On Saturday, April 06, 2013 09:37:44 PM Chet Ramey wrote:
On 4/6/13 4:48 AM, Dan Douglas wrote:
I couldn't find anything obvious in POSIX that implies which
interpretation is
correct. Assuming it's unspecified.
Bash (4.2.45) uniquely does interpret such escapes for [[, which makes me
the most portable way to assign multiple elements to an indexed array
other than a separate assignment for each element.
- The combination `set -sA' provides a means of sorting (lexicographically).
Bash currently has no built-in way to sort an array or the positional
parameters.
--
Dan Douglas
Can you whittle this down to the smallest reproducer and post a stand-alone
synthetic testcase with sample input data that fails?
If the goal is simulating exported arrays, there are other methods that
would probably work out better.
--
Dan Douglas
to not recognize
declaration commands (which is unfortunate IMO), then you would expect the 2nd
case above to be the same as the 3rd case. Instead, it's not wordsplitting and
not failing due to the () metacharacters, and using sort of a hybrid of the
two.
--
Dan Douglas
export the
variable to the environment in this case, but just localizes it, and requires
a separate export.)
--
Dan Douglas
as ordinary assignments
nor ordinary expansions.
--
Dan Douglas
the wait. Process substitutions do set $! in Bash, not
in Zsh.
--
Dan Douglas
be kept as-is.
I think the root of the problem is trying to force unquoted $@ to be like $*
instead of the other way around. That's how bash (if not for the bug) and
ksh93 manage to do this while remaining consistent with the spec.
--
Dan Douglas
that's an excellent strategy. :)
--
Dan Douglas
On Sunday, February 24, 2013 10:26:52 PM Thorsten Glaser wrote:
Dan Douglas dixit:
Zsh and pdkshes produce:
one:::two:three:::four
For all of the above, which I think is wrong for the last 4. ksh93
produces:
Why is it incorrect?
This test was intended to demonstrate expansions
On Sunday, February 24, 2013 02:43:03 PM Chris Down wrote:
Hi all,
Unless I'm misunderstanding how it should work, `cd -P -e' does not work as
specified by the documentation. From `help cd':
Yep, see: http://lists.gnu.org/archive/html/bug-bash/2013-01/msg00099.html
--
Dan Douglas
until
one of the most recent alphas. I take it that this is sort of an extra special
feature that most shells with -d happen to share, and not merely a necessary
consequence of -d with an empty arg.
Hopefully someday `mapfile' will inherit an analogous feature.
--
Dan Douglas
On Wednesday, January 30, 2013 11:35:55 AM Chet Ramey wrote:
On 1/30/13 2:47 AM, Dan Douglas wrote:
No, $* always expands to a single word. If multiple words result, those
are
the result of field-splitting, not an intrinsic multi-word expansion as in
the
case of $@. Though POSIX
-document, which might make the issue not so straightforward).
--
Dan Douglas
Zsh and pdkshes produce:
one:::two:three:::four
For all of the above, which I think is wrong for the last 4. ksh93 produces:
one:::two three:::four
for the last 4, which I think is correct.
--
Dan Douglas
On Wednesday, January 30, 2013 02:00:26 AM Chris F.A. Johnson wrote:
On Wed, 30 Jan 2013, Dan Douglas wrote:
Hi everyone, and welcome to another edition of IBOTD (IFS-bug-of-the-day),
featuring everyone's favorite Bourne shell kludge: word-splitting!
On today's episode - inconsistencies
On Saturday, January 19, 2013 02:47:38 PM Chet Ramey wrote:
On 1/18/13 4:10 PM, Dan Douglas wrote:
In scripts it breaks POSIX, conflicts with the coproc operator in kshes,
applies the redirections in an unintuitive order since the same operator
redirects stdout first, then applies
|.
--
Dan Douglas
=20 x=: POSIXLY_CORRECT=; while printf %s ${x:--) }; ((n--)); do x=
${x:-true ${x:=:}}; done )
:-) :-) :-) :-) :-) :-) :-) :-) :-) :-)
--
Dan Douglas
Oops nevermind, I see the issue now. Couldn't reproduce here either. Neither
with compat modes nor the real versions.
--
Dan Douglas
that means to inhibit brace expansion
subst.c
- brace_expand_word_list: suppress brace expansion for words with
W_NOBRACE flag
--
Dan Douglas
On Sunday, January 13, 2013 04:54:59 PM Chet Ramey wrote:
On 1/9/13 2:00 PM, Dan Douglas wrote:
When expanding simple commands, steps 3 and 4 are reversed unconditionally
for
all command types and number of words expanded, even in POSIX mode.
http://pubs.opengroup.org/onlinepubs
Yes some use -u / -e for debugging apparently. Actual logic relying upon those
can be fragile of course. I prefer when things return nonzero instead of
throwing errors usually so that they're handleable.
--
Dan Douglas
On Friday, January 11, 2013 10:39:19 PM Dan Douglas wrote:
On Saturday, January 12, 2013 02:35:34 AM John Kearney wrote:
BTW, your wrappers won't work. A wrapper would need to implement format
Hrmf I should have clarified that I only meant A complete printf wrapper would
be difficult
: value too great for base (error token is 8#9)
post
Only applies to non-POSIX mode.
--
Dan Douglas
signature.asc
Description: This is a digitally signed message part.
.
--
Dan Douglas
signature.asc
Description: This is a digitally signed message part.
On Friday, January 11, 2013 09:39:00 PM John Kearney wrote:
Am 11.01.2013 19:38, schrieb Dan Douglas:
$ set --; printf %q\\n $@
''
printf should perhaps only output '' when there is actually a
corresponding
empty argument, else eval $(printf %q ...) and similar may give
On Friday, January 11, 2013 09:48:32 PM John Kearney wrote:
Am 11.01.2013 19:27, schrieb Dan Douglas:
Bash treats the variable as essentially undefined until given at least an
empty value.
$ bash -c 'typeset -i x; [[ -v x ]]; echo $?, ${x+foo}; typeset -p x'
1,
bash: line
On Friday, January 11, 2013 04:37:56 PM Chet Ramey wrote:
On 1/11/13 4:05 PM, Dan Douglas wrote:
I don't understand what you mean. The issue I'm speaking of is that printf
%q
produces a quoted empty string both when given no args and when given one
empty arg. A quoted
format specifiers which act like they
were given a null or zero argument if more formats than arguments are given.
We already had pretty much this same discussion here:
http://lists.gnu.org/archive/html/bug-bash/2012-12/msg00083.html
It somehow slipped my mind.
--
Dan Douglas
fault
There were others, mostly to do with modifying the variable being mapped.
--
Dan Douglas
signature.asc
Description: This is a digitally signed message part.
# ...
...# Everything else same as dash
I don't know why this order was chosen or what the advantages to one over the
other might be.
--
Dan Douglas
signature.asc
Description: This is a digitally signed message part.
, error)
}
}
#endif
- else if (expandable_redirection_filename (temp))
+ else if (0)
{
expandable_filename:
if (posixly_correct interactive_shell == 0)
--
Dan Douglas
signature.asc
Description: This is a digitally signed message part.
)) )# No error
$ ( y=(1 2); (( _ = y[0], _ = 1 )) ) # crash
Segmentation fault
$ ( y=(1 2); (( _ = y[0] )) ) # No error
lvalue doesn't matter. It's just any two assignments in which the first
dereferences an array with an index given.
--
Dan Douglas
paragraphs are word-for-word identical between Bash and
multiple other manuals. Best bet is to learn to navigate it quickly.
--
Dan Douglas
be evaluated as if a zero argument were supplied.
Ooh ok... hrm I didn't consider it's actually consistent with everything else
this way.
--
Dan Douglas
strings with even length, while +(???) matches
those with odd length. +(?) matches any string with at least one character,
and any number of ?'s matches multiples of that length.
$ ksh -c 'printf %R\\n \?'
^.$
$ ksh -c 'printf %R\\n +(?)'
^(.)+$
$ ksh -c 'printf %R\\n +(??)'
^(..)+$
--
Dan Douglas
On Thursday, December 13, 2012 09:25:02 PM DJ Mills wrote:
+(???) matches lengths that are multiples of 3, not all odd-length files.
?+(??) would match odd-length files.
My bad :)
--
Dan Douglas
around overloaded variable names in outer scopes, except would allow
both reading and writing to any scope from any deeper scope (provided the
reference itself hasn't been covered up). This would be extremely useful for
shell libraries.
--
Dan Douglas
101 - 200 of 241 matches
Mail list logo