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
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" == "$
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
jus
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/
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
ev
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
Am 04.08.2010 16:38, schrieb Clark J. Wang:
On Wed, Aug 4, 2010 at 8:27 PM, Bernd Eggink wrote:
Am 04.08.2010 12:39, schrieb Clark J. Wang:
I was testing the precedence between functions and aliases so I tried like
this (with bash 4.1.5):
$ cat rc
alias foo='echo this is the alias&
pts):
http://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 decl
mand, if unquoted, is
checked to see 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
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 Eggink writes:
eval "function $name
Don't use function, use "$name ()" instead.
What's wrong with function??
Am 02.08.2010 19:15, schrieb Andreas Schwab:
Bernd Eggink writes:
eval "function $name
Don't use function, use "$name ()" instead.
What's wrong with function??
Bernd
--
Bernd Eggink
http://sudrala.de
toload f1 f2 f3' in ksh) creates small placeholder
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
t this to print "monday, 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
ere is only a choice 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
[ function ] name () 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
Am 15.07.2010 10:35, schrieb Andreas Schwab:
"Dr. Werner Fink" writes:
a=$((/bin/cat|wc -l)<
Useless subshell.
a=$({ /bin/cat | wc -l; }<
...and useless cat:
a=$(wc -l <Nevertheless, IMHO the OP's version should work. It works in ksh, for
example.
Ber
}; 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
c) ; what means 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; n<4; 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:
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.
once used some ls -l "$SCRIPTS" | sed -e 's/.* -> //' magic to replace it
(and it worked two minutes ago on the HP-UX, just like it used to back in the old days).
I once wrote a more generic shell function for this purpose, see:
http://sudrala.de/en_d/shell-getlink.html
Bernd
--
Bernd Eggink
http://sudrala.de
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 fr
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
Am 12.12.2009 15:25, schrieb DennisW:
On Dec 12, 4:24 am, Bernd Eggink wrote:
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
Am 12.12.2009 15:25, schrieb DennisW:
On Dec 12, 4:24 am, Bernd Eggink wrote:
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
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
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
t, declare, 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
ho $qq
# result is null
Fix:
Either fix the docs to tell people that a pipe is not allowed or fix
the code to allow it.
The problem is not the pipe but the fact that 'command which does nothing. If you want 'program' to read from 'file',
use '
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
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
directory part. After all, 'find -name' matches names, not paths (if you
want to match full paths, use 'find -path'). 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
PLY=($(IFS=: compgen -W "$list"))
}
complete -F _aha aha
Typing aha 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
lf. Try this:
_mm2() {
local cur files
cur=${COMP_WORDS[COMP_CWORD]}
files=$(find /home/mathias/Videos/movies/ -iname "$cur*.avi" -type
f -printf "%P\n")
local IFS=$'\n'
COMPREPLY=($files)
}
Regards,
Bernd
--
Bernd Eggink
http://sudrala.de
t=$(printf "%s:" /home/mathias/Videos/movies/*)
IFS=: compgen -W "$list" -- $zc
Regards,
Bernd
--
Bernd Eggink
http://sudrala.de
-else clause by
mkdir -p $CURRENT_DIR
cd $CURRENT_DIR
rm -f *
provided the options are supported on your system.
Regards,
Bernd
--
Bernd Eggink
http://sudrala.de
%T)]...@\h:\w]\\$\[\033[0m\] "
This works correctly with bash 4.0.24.
Regards,
Bernd
--
Bernd Eggink
http://sudrala.de
; i < 15000; ++i ))
do
echo $i > /dev/null
done
instead. Consumes nearly no memory at all.
Cheers,
Bernd
--
Bernd Eggink
http://sudrala.de
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
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
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
(
You can enter as many ')' as you like, 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
p) here:
http://www.sudrala.de/en_d/shell-cmdexp.html
Maybe it is of use for you, too.
Regards,
Bernd
--
Bernd Eggink
http://sudrala.de
em to like it and I
can't figure it out.
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
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
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?
Regards,
Bernd
--
Bernd Eggink
http://sudrala.de
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:
.
Is that a bug? I can 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
are set.
Regards,
Bernd
--
Bernd Eggink
http://sudrala.de
rue
Don't know about 3.0.14, but it looks like it performed expansion on the
regexp, while 3.2.39 leaves it unchanged.
Regards,
Bernd
--
Bernd Eggink
http://sudrala.de
ant something like:
for i in `find . -name \*gif`; do identify -format "$i %w" $i 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
The value of this variable is not automatically
reset if you start another getopts loop, you have to do it yourself:
OPTIND=1
while getopts "ow:" opt
do
...
done
Regards,
Bernd
--
Bernd Eggink
http://sudrala.de
e 3) with the last
unpaired left paren (in $( ). Using (3) and (4) instead makes the
example work.
Unpaired parens are hideous anyway, IMHO.
Regards,
Bernd
--
Bernd Eggink
[EMAIL PROTECTED]
http://sudrala.de
' in the first
example appears to be some kind of 'super-nothing'.
Regards,
Bernd
--
Bernd Eggink
[EMAIL PROTECTED]
http://sudrala.de
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
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
same name, but that
doesn't matter) 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
Paul Jarc schrieb:
Bernd Eggink <[EMAIL PROTECTED]> wrote:
My impression is that the pattern lookup depends on whether or not a
!' is involved. If the pattern does not contain a '!', the shell looks
for matching substrings, from left to right. If it contains a '!
ubstring matching the pattern "not a sequence of at least one digit"
would have been 'a' (or maybe 'ab'), and the output would have been
'12Xb34' (or '12X34').
IMHO (please correct me if I'm wrong) this contradicts the usual meaning
of the '!' operator and makes it nearly useless - except in the simple
"echo !(foo)" case you mentioned.
Bernd
--
Bernd Eggink
[EMAIL PROTECTED]
http://sudrala.de
$x unchanged.
I'm not sure whether this is a bug or I (we) miss something.
Interestingly, ksh behaves the same way. Can anybody clarify this?
Regards,
Bernd
--
Bernd Eggink
[EMAIL PROTECTED]
http://sudrala.de
asdf
don't print
The reason is that `check_file` is executed in a subshell, so 'exit'
just leaves the subshell, not the script itself.
The command substitution is unnecessary anyway, as the result (if any)
will simply be $1 itself. Thus, if you replace the main part by
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 wo
t: -bash: ${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
[E
ess than or equal to, greater than, or greater than or equal
to arg2, respectively. Arg1 and arg2 may be positive or negative integers.
Personally, I like the bash documentation because it is complete and
concise.
Greetings,
Bernd
--
Bernd Eggink
[EMAIL PROTECTED]
http://sudrala.de
Pierre Gaston schrieb:
On 10/27/07, Bernd Eggink <[EMAIL PROTECTED]> wrote:
Pavel Gorshkov schrieb:
Description:
Regexp matching seems to be broken since 3.2.0.
Repeat-By:
The following used to work in bash-3.1:
$ [[ test =~ 't.*t' ]]; echo $?
1
It w
ed. I, too, 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
(1)-release (i686-pc-linux-gnu)
Without 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
t0nedef schrieb:
echo "Please enter a network name"
read ESSID
if [ -n $ESSID ]
You probably meant:
if [ -z $ESSID ]
then
echo "unable to use a blank network name"
exit $E_NOESSID
fi
Regards,
Bernd
--
Bernd Eggink
[EMAIL PROTECTED]
http://sudrala.de
t;^[[42maha^[[0m" one two three; do : ; done
1) aha 3) two
2) one 4) three
#?
(On a terminal, the first word has a green background).
Regards,
Bernd
--
Bernd Eggink
[EMAIL PROTECTED]
http://monoped.de
___
Bug-bash mail
{x[*]//#/y} # output: a1 a2 a3
echo ${x[*]//#a/y} # output: a1 a2 a3
echo ${x[*]//a/y} # output: y1 y2 y3
--
Bernd Eggink
[EMAIL PROTECTED]
http://monoped.de
___
Bug-bash mailing list
Bug-bash@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-bash
69 matches
Mail list logo