Pattern replacement fails if string contains multibyte characters

2007-09-28 Thread Bernd Eggink
multibyte chars, replacement works as expected. I looks like a bug, or am I misssing something? Regards, Bernd -- Bernd Eggink [EMAIL PROTECTED] http://sudrala.de

Re: regexp matching broken in bash-3.2.x?

2007-10-27 Thread Bernd Eggink
, think it's a bug, as according to the docs, quote removal should be performed on the words between [[ and ]]. Regards, Bernd -- Bernd Eggink [EMAIL PROTECTED] http://sudrala.de

Re: Bash string substitution bug (?)

2008-01-11 Thread Bernd Eggink
: ${HOSTNAME: bad substitution Apparently bash interprets this as ${parameter/pattern/string} where pattern = ${HOSTNAME. Looks like a bug; it works in ksh. As a workaround, you could use: H=${HOSTNAME/.*} echo ${CLUSTER/$H} Regards, Bernd -- Bernd Eggink [EMAIL PROTECTED] http

Re: Bash string substitution bug (?)

2008-01-11 Thread Bernd Eggink
Chet Ramey schrieb: Bernd Eggink wrote: prompt: CLUSTER='1 2'; echo ${CLUSTER/${HOSTNAME/.*}} output: -bash: ${HOSTNAME: bad substitution Apparently bash interprets this as ${parameter/pattern/string} where pattern = ${HOSTNAME. Looks like a bug; it works in ksh

Re: Bash 3.2.25 not expanding subscript...

2008-02-12 Thread Bernd Eggink
) is unchanged. Try this instead: while read File do FileList[d]=$File (( d=d+1 )) done $(ls -1) Greetings, Bernd -- Bernd Eggink [EMAIL PROTECTED] http://sudrala.de

Re: Which Bash

2008-02-24 Thread Bernd Eggink
or 2.05b.0(1)-release? Looks like there are at least 2 versions on your system: Your login shell is probably bash-2.05b, while /opt/local/bin/bash (the latest version) is found via $PATH. Check your account data and PATH setting to verify it. Regards, Bernd -- Bernd Eggink [EMAIL PROTECTED] http

Re: PATH value doesn't get updated

2008-05-18 Thread Bernd Eggink
Peter Volkov schrieb: Better way to check if shell is login is: $ shopt | grep login_shell login_shell on You don't even have to call an external program: [[ $(shopt -p login_shell) == *-s* ]] Regards, Bernd -- Bernd Eggink [EMAIL PROTECTED] http://sudrala.de

Expanding an undefined array

2008-09-24 Thread Bernd Eggink
-nothing'. Regards, Bernd -- Bernd Eggink [EMAIL PROTECTED] http://sudrala.de

Re: Bash prints syntax error when command in $(...) contains case-esac

2008-09-30 Thread Bernd Eggink
makes the example work. Unpaired parens are hideous anyway, IMHO. Regards, Bernd -- Bernd Eggink [EMAIL PROTECTED] http://sudrala.de

Re: implementing flow control in bash

2008-10-21 Thread Bernd Eggink
if [%w 570]; done results.txt for i in $(find -name '*.gif') do w=$(identify -format %w $i) (( w 570 )) echo $i $w done Hope that helps, Bernd -- Bernd Eggink http://sudrala.de

Re: echo $s{2,3}

2008-12-13 Thread Bernd Eggink
are set. Regards, Bernd -- Bernd Eggink http://sudrala.de

Problem with function cd in bash 4.0

2009-02-23 Thread Bernd Eggink
get the intended behaviour by putting eval PS1='$PS1' at the end of the function, but that's a rather ugly workaround. Regards, Bernd -- Bernd Eggink http://sudrala.de

Re: Problem with function cd in bash 4.0

2009-02-24 Thread Bernd Eggink
Chet Ramey schrieb: Bernd Eggink wrote: I normally wrap the builtin cd into a function cd, which does some additional things and then calls the builtin. Example: function cd { local list=$(echo *.bui) # ... builtin cd $1 } I have a PS1 like this: PS1=\\w

Re: Behaviour of cd changed?

2009-02-24 Thread Bernd Eggink
Chet Ramey schrieb: Bernd Eggink wrote: I'm still having problems with the cd builtin. In bash 3, the commands cd cd both changed to the user's home directory. In bash 4 (with patch save-current-token applied) cd does nothing. Bug or feature? I get the same behavior from bash

Re: reference dir ../common in script

2009-03-06 Thread Bernd Eggink
. Thanks for any help, Duane You have a wrong logic. This script will mkdir if it exists. use [ ! -d ${CommonDir} ] Or use mkdir -p $CommonDir Bernd -- Bernd Eggink http://sudrala.de

Re: feature-request: brief syntax for $(type -p somecommand)

2009-04-02 Thread Bernd Eggink
-cmdexp.html Maybe it is of use for you, too. Regards, Bernd -- Bernd Eggink http://sudrala.de

Bug: 'case' in command substitution not handled correctly

2009-04-15 Thread Bernd Eggink
, the shell still wants another one. This variant works, however: x=$(case $a in (1) echo one;esac ) Regards, Bernd -- Bernd Eggink http://sudrala.de

Re: Bug: 'case' in command substitution not handled correctly

2009-04-16 Thread Bernd Eggink
Chet Ramey schrieb: Bernd Eggink wrote: GNU bash, Version 4.0.17(1)-release (i686-pc-linux-gnu) The shell doesn't recognize the closing parenthesis of a command substitution if a 'case' command is included and 'esac' is preceded by newline. Example: x=$(case $a in (1) echo one esac ) Try

Crash in hashlib.c

2009-04-17 Thread Bernd Eggink
with unallocated block argument Abbruch... Program received signal SIGABRT, Aborted. 0xe424 in __kernel_vsyscall () Appended is a stack trace. Hope it helps. Regards, Bernd -- Bernd Eggink http://sudrala.de malloc: hashlib.c:306: assertion botched free: called with unallocated block argument

Re: Crash in hashlib.c

2009-04-19 Thread Bernd Eggink
Chet Ramey schrieb: Bernd Eggink wrote: Version: GNU bash, Version 4.0.17(1)-release (i686-pc-linux-gnu) (plus newline-shellmeta patch). A script which uses, among other things, 3 associative arrays and a coprocess, crashes reproducibly with an allocation error: malloc: hashlib.c:306

Re: bash prompt misbehaving - correction.

2009-06-30 Thread Bernd Eggink
[0m\] This works correctly with bash 4.0.24. Regards, Bernd -- Bernd Eggink http://sudrala.de

Re: Help with script - doesn't work properly from cron

2009-07-18 Thread Bernd Eggink
. Regards, Bernd -- Bernd Eggink http://sudrala.de

Re: Strange compgen behaviour

2009-09-23 Thread Bernd Eggink
$list -- $zc Regards, Bernd -- Bernd Eggink http://sudrala.de

Re: Strange compgen behaviour

2009-09-24 Thread Bernd Eggink
/ -iname $cur*.avi -type f -printf %P\n) local IFS=$'\n' COMPREPLY=($files) } Regards, Bernd -- Bernd Eggink http://sudrala.de

Re: Strange compgen behaviour

2009-09-24 Thread Bernd Eggink
=: compgen -W $list)) } complete -F _aha aha Typing aha Tab cycles through 6 items a, b, c, d, e, f, whereas I would expect 3 items 'a b', 'c d', 'e f'. It looks like compgen splits the argument to -W on $IFS _and_ whitespace. Or am I missing something? Regards, Bernd -- Bernd Eggink http

Re: Strange compgen behaviour

2009-09-25 Thread Bernd Eggink
'). I'd also rather use printf %P\n (capital P) instead of %p, the results look nicer (IMHO). Regards, Bernd -- Bernd Eggink http://sudrala.de

Wrong 'declare -A' causes segfault

2009-11-25 Thread Bernd Eggink
GNU bash, version 4.0.35(1)-release (i686-pc-linux-gnu) The following syntactically wrong declaration causes a segmentation fault: declare -A x=y It should issue an error message instead. Regards, Bernd -- Bernd Eggink http://sudrala.de

Re: Wrong 'declare -A' causes segfault

2009-11-26 Thread Bernd Eggink
Am 26.11.2009 01:47, schrieb Chet Ramey: Bernd Eggink wrote: GNU bash, version 4.0.35(1)-release (i686-pc-linux-gnu) The following syntactically wrong declaration causes a segmentation fault: declare -A x=y It should issue an error message instead. It's not actually a syntax error

Re: Use of pipe in $( filename | program) returns null

2009-11-28 Thread Bernd Eggink
-- Bernd Eggink http://sudrala.de

Re: add a way to declare global variables

2009-12-12 Thread Bernd Eggink
, and local are synonyms. Using 'local' outside a function is an error, so IMHO this command is completely redundant. It _would_ make some sense, however, if its counterpart 'global' existed, as it could help clarify the intended usage of the variable. Bernd -- Bernd Eggink http://sudrala.de

Re: add a way to declare global variables

2009-12-12 Thread Bernd Eggink
second that. I'm missing this feature badly. Presently, you can only get around this restriction by using a lot of ugly and dangerous 'eval's. Bernd -- Bernd Eggink http://sudrala.de

Re: add a way to declare global variables

2009-12-12 Thread Bernd Eggink
Am 12.12.2009 11:24, schrieb Bernd Eggink: Am 12.12.2009 02:11, schrieb Matthew Woehlke: konsolebox wrote: I hope the development team will also consider adding a way in bash to declare global variables inside a function perhaps either with an option in typeset or declare like -g (same as zsh

Re: add a way to declare global variables

2009-12-12 Thread Bernd Eggink
Am 12.12.2009 21:41, schrieb Chet Ramey: On 12/12/09 5:28 AM, Bernd Eggink wrote: Am 10.12.2009 10:40, schrieb konsolebox: I hope the development team will also consider adding a way in bash to declare global variables inside a function perhaps either with an option in typeset or declare like

Re: add a way to declare global variables

2009-12-14 Thread Bernd Eggink
Am 12/14/09 13:37, schrieb Marc Herbert: Bernd Eggink a écrit : To avoid misunderstandings, let me add that you are right (only) with respect to variables being used _without_ declaration. OK, but not having to explicitly declare variables is a feature that most people expect from dynamic

Re: Is there a special variable for the directory where the script is in?

2010-02-12 Thread Bernd Eggink
Am 12.02.2010 15:39, schrieb Greg Wooledge: On Fri, Feb 12, 2010 at 02:53:39PM +0100, Bernd Eggink wrote: I once wrote a more generic shell function for this purpose, see: http://sudrala.de/en_d/shell-getlink.html You note that it doesn't handle names containing -, which is true. I'll get

Re: create array in loop with variable in array's name

2010-05-29 Thread Bernd Eggink
that first element of array1[0]=a and for example third element of array3[2]=c. This is the way how I do it : for (( n=1; n4; n++ )) do array$n=(a b c) done ...but there is syntax error That's because array$n isn't a valid name. Use eval: eval array$n=(a b c) Bernd -- Bernd Eggink

Wrong alignment in select lists

2010-05-31 Thread Bernd Eggink
}; do :; done# wrong select x in amö blah{1..20}; do :; done # OK Bash version is 4.1.7(1)-release, LANG is de_DE.UTF-8. Bernd -- Bernd Eggink http://sudrala.de

Re: [bash-bug] parsing error with heredoc and command substitution

2010-07-15 Thread Bernd Eggink
, for example. Bernd -- Bernd Eggink http://sudrala.de

Re: function grammar

2010-07-19 Thread Bernd Eggink
() compound-command [redirection] and do not see the version you show without the parens. It's there. Look at the 3rd sentence: If the function reserved word is supplied, the parentheses are optional. Bernd -- Bernd Eggink http://sudrala.de

Indirect expansion and arrays

2010-07-29 Thread Bernd Eggink
between passing all elements to a function, which is time-consuming, or using eval, which is cumbersome and error-prone. Regards, Bernd -- Bernd Eggink http://sudrala.de

Re: weird behaviour of ((count++)) when using , , to change to lower case

2010-08-01 Thread Bernd Eggink
, monday, tuesday, since you left out the ++ in the first term. I think the problem is that the ,, operator causes each expression to be evaluated twice. That would explain this behaviour, and it's a bug IMHO. Regards, Bernd -- Bernd Eggink http://sudrala.de

Re: RFE? request for an undefined attribute for functions

2010-08-02 Thread Bernd Eggink
functions f1, f2, and f3. The first call to any of these functions will replace its definition by the one found in $FUNCDIR, and also call the latter. I'm not sure, however, if this is guaranteed to work in any case (and in any bash version). Greetings, Bernd -- Bernd Eggink http://sudrala.de

Re: RFE? request for an undefined attribute for functions

2010-08-02 Thread Bernd Eggink
Am 02.08.2010 19:15, schrieb Andreas Schwab: Bernd Egginkmono...@sudrala.de writes: eval function $name Don't use function, use $name () instead. What's wrong with function?? Bernd -- Bernd Eggink http://sudrala.de

Re: RFE? request for an undefined attribute for functions

2010-08-02 Thread Bernd Eggink
Am 02.08.2010 20:16, schrieb Eric Blake: On 08/02/2010 12:15 PM, Bernd Eggink wrote: Am 02.08.2010 19:15, schrieb Andreas Schwab: Bernd Egginkmono...@sudrala.de writes: eval function $name Don't use function, use $name () instead. What's wrong with function?? 'function name

Re: Issues when func name is the same with an alias

2010-08-04 Thread Bernd Eggink
if has an alias. Therefore 'foo' in your function declaration is replaced by 'echo this is the alias'. Unfortunately, you can't quote the function name in the declaration, so you have to either use 'function' or say unalias foo first. Regards, Bernd -- Bernd Eggink http://sudrala.de

Re: Issues when func name is the same with an alias

2010-08-04 Thread Bernd Eggink
://www.chiark.greenend.org.uk/~sgtatham/aliases.html Interesting article. One thing not mentioned there is declarations. alias assoc='declare -A ' assoc x y z Not particularly useful, but you can't replace that with a function (as long as there is no 'global' option for declare). Bernd -- Bernd Eggink http

Re: Issues when func name is the same with an alias

2010-08-04 Thread Bernd Eggink
definition. I suppose that is just a documentation issue. Can anybody comment on this? Regards, Bernd -- Bernd Eggink http://sudrala.de

Re: Bash-4.2-rc2 available for FTP

2011-02-02 Thread Bernd Eggink
, as opposed to 0.2 seconds with 4.1-9. Counting from 1 to 1 is about 20 times slower. Maybe due to heavy debugging? Regards, Bernd -- Bernd Eggink http://sudrala.de

Re: equivalent of Linux readlink -f in pure bash?

2011-08-09 Thread Bernd Eggink
On 09.08.2011 03:44, Jon Seymour wrote: Has anyone ever come across an equivalent to Linux's readlink -f that is implemented purely in bash? You can find my version here: http://sudrala.de/en_d/shell-getlink.html As it contains some corrections from Greg Wooledge, it should handle

Re: equivalent of Linux readlink -f in pure bash?

2011-08-10 Thread Bernd Eggink
On 09.08.2011 15:50, Steven W. Orr wrote: On 8/9/2011 5:29 AM, Bernd Eggink wrote: On 09.08.2011 03:44, Jon Seymour wrote: Has anyone ever come across an equivalent to Linux's readlink -f that is implemented purely in bash? You can find my version here: http://sudrala.de/en_d/shell

Re: equivalent of Linux readlink -f in pure bash?

2011-08-11 Thread Bernd Eggink
On 09.08.2011 16:54, Stephane CHAZELAS wrote: 2011-08-09, 09:50(-04), Steven W. Orr: [...] *) To remove the trailing slashes, instead of while [[ $file == */ ]] do file=${file%/} done file=${file##*/}# file name

Re: [Parameter Expansion] bug in ${variable% *}

2013-02-12 Thread Bernd Eggink
On 11.02.2013 18:50, Dashing wrote: Bash version: 4.2.042 I have a script that behaves erratically: = #! /bin/bash last=${1##* } rest=${1% *} while [[ ${rest: -1} == '\' ]]; do last=${rest##* } $last oldrest=$rest rest=${rest% *} if [[ $oldrest == $rest

Re: [Parameter Expansion] bug in ${variable% *}

2013-02-12 Thread Bernd Eggink
On 12.02.2013 18:50, Dashing wrote: On Tue, 12 Feb 2013 18:02:05 +0100 Chet Ramey I've fixed the problem, and the fix will be in the next release. Thank you, Chet! On Tue, 12 Feb 2013 10:13:46 +0100 Bernd Eggink superfluous blank in the ${rest: -1} expression Bernd, this blank makes a big