On Sun, Feb 13, 2011 at 08:17:05PM -0700, Bob Proulx wrote:
_CRed=$(tput setaf 1) #Red
_CRST=$(tput sgr0) #Reset
_CBLD=$(tput bold) #Bold
_prompt_open=
_prompt_close=
_prompt=
[[ $UID -eq 0 ]] {
_prompt_open=$_CBLD$_CRed
_prompt_close=$_CRST
On Mon, Feb 14, 2011 at 07:26:16PM -0600, Dennis Williamson wrote:
The user is performing this from a shell prompt. I had him try
[[ $BASH_VERSION =~ 4\.0 ]] echo yes || echo no
which should output yes only if he's using Bash 4.0 *and* compat31
is on.
Gah. Too much trickery and
On Tue, Feb 15, 2011 at 09:49:16PM -0600, Dennis Williamson wrote:
SECS=1275250155
export TZ=EST5EDT
printf %()T\n $SECS
printf %(%e-%b-%Y %T %Z)T\n $SECS # added %Z
result:
15:09:15
30-May-2010 15:09:15 CDT
I can't duplicate your problem on HP-UX 10.20:
imadev:~$ s=1275250155;
On Thu, Feb 17, 2011 at 10:56:21PM +0800, Clark J. Wang wrote:
The point is: ``Any part of the pattern may be quoted to force it to be
matched as a string.'' And backslash is one of bash's quoting chars. But
in my examples, a pattern with `\' in it sometimes is considered to be
quoted and
On Thu, Feb 17, 2011 at 05:07:40PM +0200, Pierre Gaston wrote:
On Thu, Feb 17, 2011 at 4:56 PM, Clark J. Wang dearv...@gmail.com wrote:
The point is: ``Any part of the pattern may be quoted to force it to be
matched as a string.'' And backslash is one of bash's quoting chars.
aaah well
On Thu, Feb 17, 2011 at 05:18:23PM -0500, Chet Ramey wrote:
Maybe if the man page had read ...to force the quoted portion to be
matched as a string this could have been avoided.
I like this answer. Removing ambiguity (it could refer to the
whole pattern or to the quoted portion) is always
On Fri, Feb 18, 2011 at 11:25:48AM +0800, Clark J. Wang wrote:
A global var can always be declared out of a func (usually at the beginning
of the script) so what's the main intention of introducing a new `-g'
option?
The main reason, as I understand it, is so that you can declare an
On Fri, Feb 18, 2011 at 10:32:13PM +0100, Peter Hofmann wrote:
$ echo $(echo {1..3})
1 2 3
Huh?
Brace expansion is a funny thing. My belief at the moment -- I'm sure
someone will correct me if I'm wrong -- is that because you've got
everything quoted up, it's all seen as one word by the
On Fri, Feb 18, 2011 at 10:53:31PM +0100, Andreas Schwab wrote:
Greg Wooledge wool...@eeg.ccf.org writes:
On Fri, Feb 18, 2011 at 10:32:13PM +0100, Peter Hofmann wrote:
$ echo $(echo {1..3})
1 2 3
Huh?
Brace expansion is a funny thing. My belief at the moment -- I'm sure
On Fri, Feb 18, 2011 at 04:36:06PM +0100, Steffen Daode Nurpmeso wrote:
I am not a sophisticated shell programmer, but i really think this
time it's a shell fault.
You think *what* is the shell's fault?
You may invoke the code snippet via 'script test1 test3' or so.
#!/bin/sh
On Mon, Feb 21, 2011 at 04:05:34PM +0800, jida...@jidanni.org wrote:
There is no way to give the 'select' command a default value, so all the
user does is need to hit return.
$ help select
... If the line is empty, WORDS and the prompt are redisplayed.
`select' is extremely limited. If
On Tue, Feb 22, 2011 at 08:03:39PM -0800, Micah Cowan wrote:
Bash's special builtin [[ ]] syntax also provides both wildcards, and
(much more powerful) extended regexes (roughly similar to Perl regexes;
they're what egrep uses).
Just for the record, ERE (Extended Regular Expressions), as used
On Thu, Feb 24, 2011 at 02:55:13PM -0500, Steven W. Orr wrote:
I have three arrays
a1=(aaa bbb ccc ddd)
a2=(qqq www eee rrr)
a3=(fff ggg hhh)
I then set a_all
a_all=(${a1[*]} ${a2[*]} ${a3[*]}
Missing ). Also, a far more serious problem, you used * when you should
have used @.
On Thu, Feb 24, 2011 at 06:59:02PM -0500, Steven W. Orr wrote:
I intentionally used the star instead of the atsign because I'm taking
advantage of the fact that these array elements all have no whitespace. So,
after the assignment to a_all, the value of a[0] is equal to the single
string
On Fri, Feb 25, 2011 at 09:46:58AM +, Davide Brini wrote:
Maybe, but then it shouldn't escape the $ either, as the OP is reporting for
4.2 (I don't have a 4.2 handy to test it).
I actually noticed this quite recently, but didn't think to bring it up.
I had just typed some cd command, and
On Tue, Mar 01, 2011 at 10:20:29AM -0500, Chet Ramey wrote:
*** ../bash-4.2-patched/variables.c 2011-02-25 12:07:41.0 -0500
--- variables.c 2011-03-01 10:13:04.0 -0500
***
*** 3661,3665
v = find_variable (name);
! if (exported_p (v))
On Mon, Mar 07, 2011 at 03:22:26PM -0500, Steven W. Orr wrote:
foo='sleep 100 - 2- '
Sleep for 100 seconds and then close channel 1 and channel 2.
No. Redirections are done first.
On Thu, Mar 10, 2011 at 10:18:26AM +0800, Clark J. Wang wrote:
Actually I don't like the recursion here. Does POSIX require that?
For example:
unset a; declare a=a; [[ a -lt 3 ]]; echo $?
bash: [[: a: expression recursion level exceeded (error token is a)
1
POSIX doesn't even have a
On Thu, Mar 10, 2011 at 10:22:12AM +0800, Jerry Wang wrote:
var=abcabc
echo var: ${var}
echo replace the leading \ab\ to uppercase: ${var^ab} # expect to
get ABcabc ?
The documentation is a bit terse, admittedly. What the ^ operator
does is compare the *first character* of
On Thu, Mar 10, 2011 at 11:42:25AM -0800, Philip Prindeville wrote:
My request is simple.
HAH! Lies
Using termcap/ncurses info (which you need anyway
for the readline stuff), it would be nice to have the option of running
commands in a pseudo-tty and then bracketing the output from
On Thu, Mar 10, 2011 at 12:49:27PM -0800, Micah Cowan wrote:
When both stdout and stderr are the same tty, how do you expect to use
this method to detect which text should be hilighted and which shouldn't?
Arrange so that's not the case. Most likely by running something like
magicthing
On Mon, Mar 14, 2011 at 10:00:14AM +0100, Roman Rakus wrote:
$ locale
LANG=en_US.UTF-8
LC_CTYPE=en_US.UTF-8
LC_NUMERIC=en_US.UTF-8
LC_TIME=en_US.UTF-8
LC_COLLATE=en_US.UTF-8
LC_MONETARY=en_US.UTF-8
LC_MESSAGES=en_US.UTF-8
LC_PAPER=en_US.UTF-8
LC_NAME=en_US.UTF-8
LC_ADDRESS=en_US.UTF-8
On Wed, Mar 16, 2011 at 10:54:15AM +, Barrie Stott wrote:
The script that follows is a cut down version of one that came from elsewhere.
#!/bin/bash
cp /tmp/x.html /tmp/$$.html
ls /tmp/$$.html
[ $DISPLAY ] open /tmp/$$.html
ls /tmp/$$.html
rm -f /tmp/$$.html
If I comment out the
On Sat, Mar 19, 2011 at 09:52:05PM +, Zeev Tarantov wrote:
configure:3122: checking for C compiler default output file name
configure:3144: x86_64-pc-linux-gnu-gcc -g -O2 -flto
-DDEFAULT_PATH_VALUE='/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
On Thu, Mar 24, 2011 at 02:33:19PM +, Marc Herbert wrote:
I would also like to see this example in the documentation:
$ ( echo sub-$BASH_SUBSHELL ); echo main-$BASH_SUBSHELL
sub-1
main-0
Overkill. Most of the other features in the manual do not have such
examples, and if we added
On Thu, Mar 24, 2011 at 06:07:33PM +, Marc Herbert wrote:
Not every feature is complicated enough that it requires special
documentation care and that it raises a discussion here.
BASH_SUBSHELL isn't complicated at all. It's just documented in a
confusing way. It doesn't require an
On Fri, Mar 25, 2011 at 02:25:35PM -0700, tytus64 wrote:
while read line
do
line_num=`expr $line_num + 1`
echo $line_num: $line ./out.log
done $log_file
Although it's not directly related to your question, I feel obliged
to point out that you can increment a variable without
On Mon, Mar 28, 2011 at 06:59:23AM -0700, tytus64 wrote:
Interesting...
I used kill -HUP pid instead of killall -HUP prog_name and it works
without interrupting the first loop. I also noticed 2 processes running when
the first loop is iterating but only 1 when the second loop is iterating:
On Mon, Mar 28, 2011 at 10:53:21AM -0700, Linda Walsh wrote:
if [ ! -e $d/S??sshd ]; then echo sshd not enabled; fi
That will fail quite colorfully if the glob matches multiple files.
(Also, $d should be quoted.)
On IRC we recommend enabling nullglob, pulling the results of the glob
into an
On Tue, Mar 29, 2011 at 08:02:17AM -0400, Steven W. Orr wrote:
Is there a difference between
while read line file
do
stuff
done
vs
while read line
do
stuff
done file
Yes. It's a huge difference. In the first one, the file is re-opened
by read every time through the
On Wed, Mar 30, 2011 at 02:43:58PM +0430, ali hagigat wrote:
--
var1=word1 word2
echo $var1
if (test -z \$var1\) then
echo first
else
echo second
fi
Problems in this script:
* Unquoted $var1 on line 2. This means that instead of passing the actual
On Mon, Apr 11, 2011 at 12:23:15PM -0600, Bill Gradwohl wrote:
-BEGIN PGP SIGNED MESSAGE-
I have a tiny script to prune empty directories from a structure. The
essential line is as follows:
tree --noreport -dfi ${1} | tac | sed 's//\\/g;s/^/rmdir
- --ignore-fail-on-non-empty
On Mon, Apr 18, 2011 at 10:30:35AM -0400, Steven W. Orr wrote:
ss=1
(( ss ))
echo $? # Also says 1. Should this be 0 because it should be
the
# success result same as (( ss != 0 ))
That's not what I get:
imadev:~$ unset ss; ss=0; ((ss)); echo $?
1
imadev:~$
On Mon, Apr 18, 2011 at 10:57:00AM -0400, Steven W. Orr wrote:
I get the same result as you when I do it your way. But if I add the
typeset, I still get the same result:
515 unset ss; typeset -i ss=1; ((ss)); echo $?
0
516 unset ss; typeset -i ss=0; ((ss)); echo $?
1
Interesting. So
On Sat, Apr 23, 2011 at 11:07:06AM +0430, ali hagigat wrote:
I have a makefile and I want to print each word of the variable, .VARIABLES
on a separate line.
It seems that the previous simple solution of Mr. Johnson here does not
work, means: printf %s\n $var
make(1) is a separate program
On Tue, Apr 26, 2011 at 12:41:49PM -0400, Steven W. Orr wrote:
It turns out that when I
called getopts, I had set IFS='-'.
I assume you mean when I called die.
die()
{
typeset opt
typeset opt_s=1
typeset opt_i=0
typeset err_opts=
OPTIND=1
while getopts ':is:'
On Tue, May 03, 2011 at 09:41:28PM -0500, Jonathan Nieder wrote:
Rafael Fernandez wrote:
set -- a b c d e f g h i j k l m n o p q r s t u v w x y z
i=1
eval echo '$'$i # outputs an expected 'a'
I didn't see the original question yet, but it looks like you're
On Wed, May 04, 2011 at 10:23:20AM -0500, Shawn Bohrer wrote:
-bash-4.1$ [[ helloworld =~ oworld$ ]] echo match
-bash-4.1$
Confirmed here (HP-UX 10.20), even using the approved stuff the RE into
a variable workaround that fixes most =~ problems:
imadev:~$ bash-4.1.7
imadev:~$
On Fri, May 06, 2011 at 11:02:32AM -0400, Steven W. Orr wrote:
I wanted to write a routine to print out an array. It just takes the name
of the array as an argument.
Flee in terror. Do not look back.
Oh, wait, you want a useful answer? Switch to ksh93 and use nameref.
You CANNOT do this
On Fri, May 06, 2011 at 11:50:34AM -0400, Chet Ramey wrote:
Eric suggested %q, and that works to a
certain degree, but you can also use
printf '%s ' ${vals[@]} ; echo
and get the double-quoting you want.
Fails horribly if the array elements contain double quotes of their own.
On Fri, May 06, 2011 at 06:22:25PM +0200, Dirk wrote:
I was fooled by echo $SHELL returning /bin/bash, but when I manually
call /bin/bash before running the above command (it is not a script
yet), it works.
What the heck is going on here ... (!xmpf)
The $SHELL variable does not
On Tue, May 10, 2011 at 04:47:29AM +0200, Thomas De Contes wrote:
tDeContes-fixe:~ thomas$ echo $PS1
+ echo '\h:\W \u\$ '
\h:\W \u\$
if i do not
PS1=# $PS1
then i don't have the problem described in 1
I am not able to reproduce this in my environment. I'm using Debian 6.0
on i386, I
On Thu, May 12, 2011 at 03:13:51PM +0300, Petteri Räty wrote:
Repeat-By:
betelgeuse@pena ~/test $ echo foo a b
This one is not an error; it simply does not mean what you think it means.
The following commands are all equivalent:
echo foo a b
echo a foo b
a echo foo b
echo foo b a
On Wed, May 18, 2011 at 02:10:39PM +0200, Rafaël Fourquet wrote:
If a line containing the '\0' is read into a variable, the content
of this variable does not contain the part after the '\0' character.
Repeat-By:
echo -e 'a\0b' | (read f; echo $f)
The output
On Thu, May 19, 2011 at 03:23:55PM +0200, Rafaël Fourquet wrote:
I have a program which outputs groups of filenames. Each group is separated
by a newline, and within each group,
each name is separated by '\0'.
That seems backwards somehow... the stronger delimiter (NUL) is used
in the inner
On Thu, May 19, 2011 at 04:30:40PM +0200, Rafaël Fourquet wrote:
Do you mean, in your example, that e.g.
... do mapfile -t files $group ; ls -1 ${files[@]}; done ...
is better than:
... do xargs -d '\n' ls -1 $group; done ...
imadev:~$ group=$'foo\nbar\nhi mom\n'
imadev:~$ xargs -d '\n'
On Fri, May 20, 2011 at 12:31:31AM -0700, Linda Walsh wrote:
1) use of of the \u and \U escape sequences
in the format string (16 and 32 bit Unicode values).
This isn't even a sentence. What bash command did you execute, and
what did it do, and what did you expect it to do?
In
On Fri, May 20, 2011 at 03:29:59PM +0200, Ralf Goertz wrote:
In bash 4.2, on a Debian 6.0 box with a UTF-8 locale, printf '\u203c\n'
I am not Linda but in my setting (4.1.10(1)-release) under linux 64bit I
have
$ printf \u203c\n
\u203c
It it a bash 4.2 feature; it does not work in bash
On Fri, May 20, 2011 at 03:03:25PM -0700, Linda Walsh wrote:
%lc uses wide chars 'wchar_t or wint_t'. These are 16 bits on
Wincygwin and 32 on with glib.
There is no such thing as a wchar_t or a wint_t in Bash. There is no
such thing as a 16-bit or 32-bit integer type, neither big-endian
On Wed, May 25, 2011 at 05:15:28PM -0400, Steven W. Orr wrote:
In addition, I wrote (what I thought was pretty clever) a function
called glob_array:
glob_array()
{
[[ snip ]]
while (( $# ))
do
arrayname=$1
pattern=$2
aval=( $pattern )
Looks like what
On Fri, May 27, 2011 at 12:35:12PM -0700, Jacoby Hickerson wrote:
When executing a test script using the #!/bin/sh interpreter line
the shell expansion for the last argument ${!#} is blank,
Good. And now you know why you use a proper #!/bin/bash shebang when
you use bash extensions in
On Fri, May 27, 2011 at 01:35:50PM -0700, Jacoby Hickerson wrote:
Although, I am curious, is this is a matter of sh
being continually updated to exclude all bash extensions
Eh? POSIX is defined by a group of people and published. Here's the
current edition:
On Fri, Jun 03, 2011 at 12:06:32AM -0700, Marcel (Felix) Giannelia wrote:
Is it really a programmer mistake, though, to assume that [A-Z] is only
capital letters?
Yes, it is. You should be using [[:upper:]], or you should be setting
LC_COLLATE=C if you insist on using [A-Z].
Oh, look, there's more!
On Fri, Jun 03, 2011 at 12:06:32AM -0700, Marcel (Felix) Giannelia wrote:
[[:alpha:]] is too difficult to type to make it useful for the kind of
quick pattern-matching that character ranges are used for on the
interactive shell. Try it. Open-bracket, colon is an
On Fri, Jun 03, 2011 at 09:15:55AM -0700, Marcel (Felix) Giannelia wrote:
Alright -- assuming that for the moment, how does one specify
[ABCDEFGHIJKL] using [[:upper:]]? This is something that I haven't seen
documented, and I'm genuinely curious.
You can't. Either write out [ABCDEFGHIJKL]
On Fri, Jun 03, 2011 at 09:12:07AM -0700, Marcel (Felix) Giannelia wrote:
And yours looks broken -- how does
echo Hello World | tr A-Z a-z
result in a bunch of non-ASCII characters?
I explain it in a bit on http://mywiki.wooledge.org/locale
In a bit more depth: in ASCII, the characters A-Z
2011/6/23 Jan Schampera jan.schamp...@web.de:
However, Mr. Wang may want to read one of Greg's brilliant FAQ entries [1].
[1] http://mywiki.wooledge.org/BashFAQ/071
On Thu, Jun 23, 2011 at 04:00:35PM +0800, Yunfeng Wang wrote:
Thanks Jan, Greg's solution is great!
Just for the record, I
On Wed, Jun 22, 2011 at 09:59:45AM -0700, sweinberger wrote:
/bin/bash /S /c
... MS-DOS 3.30? Or a modified version of bash? Or both?
In Make File:
@ls -l ./SomeDir/*
Bash Command
/bin/bash /S /c ls -l ./SomeDir/*
The /S from what I see enables regular expression processing in the
http://mywiki.wooledge.org/BashFAQ/105 -- Why doesn't set -e (set -o
errexit) do what I expected?
On Fri, Jun 24, 2011 at 06:18:08PM +0100, Rui Santos wrote:
Try this script:
#!/bin/bash
declare -ax array
array[$(( $( echo -n 1001 ) - 1001 ))]=1
this will issue an error: line 6: 1001: command not found
imadev:~$ unset array
imadev:~$ array[$(( $( echo -n 1001 ) - 1001 ))]=1
imadev:~$
On Sat, Jun 25, 2011 at 05:35:24PM +0200, lhun...@lyndir.com wrote:
arr=(a b c); echo ${arr[-1]}
In line with that, I'd like to propose extending that functionality to
other operations that address array elements:
echo ${arr[@]:0:-1} # Expected: c
echo ${arr[@]:1:-2} #
On Wed, Jun 29, 2011 at 01:42:06PM +0200, Maarten Billemont wrote:
If you expand ${arr[@]:1:2}, you get the following:
values: [ a | b | c ]
indexes: 0 1 2 3
expand: [ 1 2 ] = b c
^ start from 1
^ length 2
I propose we let a negative length
On Wed, Jun 29, 2011 at 06:41:25PM +0200, Maarten Billemont wrote:
This is where preceding the element with the index comes in handy: We start
with the index 1, which lays between element 0 and element 1.
... I have a feeling you're taking this definition from some other
language. Python
On Wed, Jun 29, 2011 at 06:41:25PM +0200, Maarten Billemont wrote:
For those to whom a cursor between elements seems confusing: think of your
prompt's cursor and imagine an element is a single character.
No wonder this makes no sense to me. Have you actually looked at the
cursor in a
On Sun, Jul 03, 2011 at 11:41:02AM -0700, Bruce Korb wrote:
P.S. this check is really for any version below 2.6.27:
- case $LINUXRELEASE in
- # ext4 was in 2.6.22-2.6.26 but not stable enough to use
- 2.6.2[0-9]*) enable_ext4='no' ;;
- *) . ;;
and might have been
On Tue, Aug 09, 2011 at 05:47:09PM -0700, Linda Walsh wrote:
Bob Proulx wrote:
This may be a good point to mention this reference:
http://www.pixelbeat.org/programming/stdio_buffering/
Does it only work with gnu programs? I.e. how would they know to
not buffer
Sounds like
On Wed, Aug 10, 2011 at 10:07:20AM -0600, Bob Proulx wrote:
The unbuffer expect script sets up a tty around the called program so
that instead of a pipe the program detects a tty.
The stdbuf utility works by setting up an LD_PRELOAD library
libstdbuf.so that replaces the libc calls and
On Wed, Aug 10, 2011 at 11:53:52AM -0700, Curtis Doty wrote:
touch -hr directory symlink
touch: illegal option -- h
Hmm, what is that? Let's check a GNU/Linux box:
-h, --no-dereference
affect each symbolic link instead of any referenced file (useful
only
On Wed, Aug 10, 2011 at 03:25:49PM -0400, Chet Ramey wrote:
The man page says:
file1 -nt file2
True if file1 is newer (according to modification date) than
file2, or if file1 exists and file2 does not.
Ah. The help test page is shorter:
FILE1 -nt FILE2 True if file1
On Wed, Aug 10, 2011 at 03:23:47PM -0700, Linda W wrote:
1 #!/bin/bash
2
30
31 # trace control for subs
32 declare -ix Allow_Trace=$(((
33 _D_LowLevel |
34 _D_Provides |
35 _D_
36 )))
I
On Thu, Aug 11, 2011 at 12:23:00AM -0700, pjodrr wrote:
they call it collapsing functions:
http://wiki.bash-hackers.org/howto/collapsing_functions
The first time you run chatter(), the function redefines itself based on the
value of verbose. Thereafter chatter doesn't check $verbose anymore, it
On Thu, Aug 11, 2011 at 12:38:17PM -0800, Roger wrote:
OK. Now I see the collapsing, and it seems more like a hidden collapse rather
then an immediately apparent collapse from an initial stance after
reading/tracing. When tracing this function, I was thinking the function
would be read each
On Thu, Aug 11, 2011 at 11:56:10PM -0700, Linda Walsh wrote:
**Exception**
declare -i a
a=0
--
As a is declared to be an integer, it has the results evaluated
at assignment time. a=0 is an integer expression that doesn't set
$?=1
Neither should:
((a=0))
a=0 is an assignment.
On Fri, Aug 12, 2011 at 08:18:42AM -0700, Linda Walsh wrote:
If I write a==0 on the bash command line, it will generate an error.
a=0 does not. 'Bash' knows the difference between an assignment and a
equality test in math.
imadev:~$ ((a==0))
imadev:~$ ((a=0))
imadev:~$ a==0
imadev:~$
On Fri, Aug 12, 2011 at 12:19:59PM -0700, Linda Walsh wrote:
Under -e, it would fail on the 'let' statement
This is one of the cases I mention on http://mywiki.wooledge.org/BashFAQ/105
-e -- in a WELL DESIGNED PROG***, where errors are caught,
shouldn't cause a otherwise working program
On Mon, Aug 15, 2011 at 12:45:58AM -0700, Linda Walsh wrote:
#!/bin/bash -exu
alias sub=function
alias unless='if !'
Aliases don't even *work* in scripts.
typeset -xr sub unless
declare -a SAVE_ARGS=( $@ )
typeset -xr snapdir='snapdir'
# in shell: white is black and black is white:
On Mon, Aug 15, 2011 at 08:19:01PM -0700, Linda Walsh wrote:
` Dennis Williamson wrote:
As has been said before, don't use bash -e.
Why don't you convince Chet to remove it then?
He can't, because people like you keep using it. Also, it's probably
mandated by POSIX. I can't be bothered
On Tue, Aug 16, 2011 at 03:41:19PM -0700, Linda Walsh wrote:
Ken Irving wrote:
Maybe this?
today_snaps=( ${snap_prefix} )
but as you mention, that will put them into an arraysorry imprecise
terminology list for me is some number of objects in a string
separated by some
On Tue, Aug 16, 2011 at 02:11:43PM -0700, Linda Walsh wrote:
2) His knowledge base about bash seems to be dated or lacking.
His page on indirect assignment skips using arith expressions and skipped
one line assignments for assigning to indirect vars using the
It's a wiki, you know. It can
On Wed, Aug 17, 2011 at 10:54:02AM +, Kiran Kotla wrote:
prog=snmpd
start() {
echo -n $Starting $prog:
}
value in the $prog displaying properly,bur the Starting message is
scrambled.
Bourne-Again shell format.
The $... quoting is for localization (natural language
On Wed, Aug 17, 2011 at 08:46:34PM -0700, Linda Walsh wrote:
how do you declare a variable for storage in the context of the caller?
(using a function)...
???
The *caller* declares it.
I found it very troublesome
inside a function, to store a value into a local variable in the caller.
On Thu, Aug 18, 2011 at 06:02:14AM -0700, Linda Walsh wrote:
The shopt -s expand_aliases feature has been in bash since I first
encountered it in ~1999.
Fine. You know more bash bad practices than I do. You win.
b=one two three
read a $b
echo $a
one two three
The word following
On Thu, Aug 18, 2011 at 08:03:41AM -0700, Linda Walsh wrote:
4.2 introduce a new -g to declare a global variable inside a function.
Which doesn't say what it would do in situations like the above.
Then let's test:
imadev:~$ echo $BASH_VERSION
4.2.10(7)-release
imadev:~$ unset a b;
On Thu, Aug 18, 2011 at 09:26:42AM -0700, Linda Walsh wrote:
It's like -e was very using in bash 3.0-4.0, but you didn't know it so
thought it worthless.
I certainly knew about -e. It was bad back then, too. It's arguably
worse now, because there are even more variants in implementation than
On Thu, Aug 18, 2011 at 12:35:37PM -0400, Steven W. Orr wrote:
lrwxrwxrwx. 1 sorr fc5 Aug 18 08:48 err - errio
-rw-rw-r--. 1 sorr fc 3816 Aug 18 08:48 errio
*836 [[ -f err ]]
837 echo $? # BAD answer
0
Sounds like you want this:
http://mywiki.wooledge.org/BashFAQ/097 - How do
On Thu, Aug 18, 2011 at 02:42:03PM -0400, Chet Ramey wrote:
The expansions are the default set as described in the quoted paragraph,
without pathname expansion and, since the result is passed to the command
as a single string, word splitting.
I think the confusion arises over the precise
On Tue, Aug 23, 2011 at 09:42:21AM -0400, Steven W. Orr wrote:
Since require is a function, any variables that
are declared in a required module which declare global variables using
typeset then become local variables to the require function. Then after the
modules are loaded, the variables
On Thu, Aug 25, 2011 at 03:09:04PM +0200, Thomas De Contes wrote:
Well, libc is a part of linux, isn't it ?
libc is the generic name for an implementation of the library of functions
required by various standards, including ISO/ANSI C, POSIX, and so on.
It's usually named libc* and located in
On Thu, Sep 01, 2011 at 01:15:34AM -0800, Roger wrote:
MAILPATH
A colon-separated list of file names to be checked for mail.
The message to be printed when mail arrives in a particular file
may be specified by separating the file name from the message
with a
On Sun, Sep 11, 2011 at 11:23:48PM -0800, Roger wrote:
When using GNU Screen (or other terminal multiplexer), I noticed the terminal
multiplexer never gives each bash shell opened, a chance to write the history
file on exit.
The usual result after an initial install for several months, the
On Sat, Sep 17, 2011 at 08:53:32PM -0400, Chet Ramey wrote:
On 9/17/11 10:26 AM, Gerard Seibert wrote:
Just out of curiosity, are there any plans to make multi-dimensional
array variables available in future versions of Bash? I would find it
extremely useful.
I don't have any current
On Sun, Sep 18, 2011 at 10:11:17PM -0800, Roger wrote:
On Mon, Sep 19, 2011 at 01:37:22AM -0400, Mike Frysinger wrote:
On Monday, September 19, 2011 01:18:02 Roger wrote:
I'm stumped on this as my history is in the format of:
$ tail ~/.bash_history
#1316296633
man bash
#1316296664
On Wed, Sep 21, 2011 at 01:09:32PM -0400, Pete Nelson wrote:
I'm confused about what exec is doing in this case.
Sample script t:
#!/bin/bash
echo $0 pid: $$ ppid: $PPID args: $* 12
if [ -z $1 ]; then
exec $0 first | $0 second
echo should not reach here
fi
It does nothing. The $0
On Mon, Sep 26, 2011 at 07:06:30PM -0800, Roger wrote:
Some good reading I found is under the Bash Manual Page section Parameter
Expansion.
From here, to learn more about regex/regexpr as the Bash Manual is quite brief
on regex, use the following manual pages:
perlretut - Gives a good
On Wed, Sep 28, 2011 at 12:43:01PM -0800, Roger wrote:
Seems I used 'man regex' as well here. AKA regex(3). But I did
realize this a few weeks ago; the real regex description being 'man 7 regex'.
The Bash Manual Page denotes only regex(3).
You're relatively fortunate that it's *that* easy to
On Thu, Sep 29, 2011 at 10:59:19AM -0500, Peng Yu wrote:
We all have discovered that regex(3) is not consistent across all the
platform. Why you say it is portable?
The three systems I mentioned earlier today all have regex(3). Which
system have you found, which doesn't have it?
As I
On Thu, Sep 29, 2011 at 11:18:57AM -0500, Peng Yu wrote:
Also, regex(3) does not mention the difference between $x =~ .txt
and $x=~ .txt. I think that the difference should be addressed
in man bash.
It already is.
An additional binary operator, =~, is available, with the
On Thu, Aug 18, 2011 at 11:10:17AM +0100, Stephane CHAZELAS wrote:
Please read BashFAQ/006: http://mywiki.wooledge.org/BashFAQ/006
no force in the universe can put NUL bytes into shell strings usefully
No, zsh supports NUL bytes in its strings happily. It's even in
the default $IFS. Where
On Mon, Oct 03, 2011 at 12:56:43PM +, Stephane CHAZELAS wrote:
If zsh is not compatible with any other shell, then bash isn't
either. What do you mean?
http://zsh.sourceforge.net/FAQ/zshfaq02.html#l10
because of all the options it is not safe to assume a general zsh run
by a user will
On Mon, Oct 03, 2011 at 02:20:26AM -0400, d...@cs.cmu.edu wrote:
PS1=\e[7m\h:\w\e[0m
You forgot to put \[ ... \] around the non-cursor-moving escape sequences.
201 - 300 of 1711 matches
Mail list logo