Hi all,
Is there fast way of splitting and joining of strings in the recent Bash
versions?
For splitting, I'm aware of
old="a,b,c"
IFS=, read -a arr <<< "$old"
For joining,
new=$(IFS=,; echo "${arr[*]}")
or
new=$(IFS=,; echo "$*")
On Sun, Jan 24, 2021 at 11:29:46AM +0800, Koichi Murase wrote:
> 2021年1月24日(日) 10:22 William Park :
> Is there a background for choosing a semicolon to split words? Zsh has
> a similar feature with a different syntax:
I'm running out of special characters, and I don't want
Eg.
echo "${*;.}"
would be equivalent to
(IFS=.; echo "$*")
Where it would be used?
- everywhere
Advantage?
- replaces multiple lines in shell function
- makes Bash script simpler and clearer
- less bookkeeping and less mistakes
--
William Park
ort seems perfectly adequate
> to me, and it can handle everything that scanf can. I'd only suggest
> extending the regular expression syntax with support for named subgroups.
Ah.. I forgot Bash now has regex. Just tried =~, and I can get the
subgroups out. Request withdrawn. :-)
--
William Park
everywhere.
Advantage:
- You can concentrate on "business logic", and less time on
bookkeeping.
--
William Park
"ver", next 10
arguments into array "rev", ...
Then, I just use variable "rev" and that would be equivalent to
${@:55:10}.
Where it would useful?
- parsing real-life CSV files
- parsing UDP packets, for prototyping.
- parsing anything that has fixed width format.
- ...
--
William Park
Another issue I came across.
declare -p name=value
thinks 'name=value' is the variable. My reading of manpage seems to say
'name' should be used, but not sure. Is this a bug?
Workaround is, of course, use separate lines,
declare name=value
declare -p name
--
William Park
l a=123
declare -p a
}
f1 # prints nothing
f2 # prints $a
--
William Park
I have feature request: stack variable. Almost like current DIRSTACK
with 'pushd' and 'popd', but for regular arrays.
I know it can be implemented with array, where you push and pop from the
end. But, a real stack is better.
--
William Park
Hi all,
I just noticed that BASH_ARGV contains commandline arguments in reverse.
$ cat > x.sh
#!/bin/sh
declare -p BASH_ARGV
^D
$ sh x.sh 1 2 3 4 5
declare -a BASH_ARGV='([0]="5" [1]="4" [2]="3" [3]="2" [4]="1")'
--
William
On Sat, Mar 16, 2013 at 10:15:50PM -0400, Chris F.A. Johnson wrote:
> On Sun, 17 Mar 2013, Chris Down wrote:
> > ExprCount() {
> > for (( i = $1 ; i > 0 ; i-- )); do
> > :
> > done
> > echo "$1 iterations"
> > }
>
>Or, in a POSIX-compliant manner:
>
> ExprCount
On Fri, Nov 11, 2011 at 04:35:32PM +0800, Clark J. Wang wrote:
> On Fri, Nov 11, 2011 at 2:25 PM, William Park wrote:
>
> > On Fri, Nov 11, 2011 at 01:48:59PM +0800, Clark J. Wang wrote:
> > > In my company all the people share a few of Solaris servers which use
> > &g
On Fri, Nov 11, 2011 at 01:48:59PM +0800, Clark J. Wang wrote:
> In my company all the people share a few of Solaris servers which use
> NIS to manage user accounts. The bad thing is that some servers' root
> passwords are well known so anybody can easily su to my account to
> access my files. To
No. For example, current Bash is copyrighted and licensed by the copyright
holder.
To get included in Bash, though, I think the license should be the same as Bash,
at the least.
--
William
- Original Message -
> From: Nicolas ARGYROU
> To: Dave Rutherford
> Cc: bashbug
> Sent: Sa
145557834293068928043467566190278008218249525830565939618481
is awfully big number! :-)
--
William
- Original Message -
> From: Nicolas ARGYROU
> To: "bug-bash@gnu.org"
> Cc:
> Sent: Friday, September 16, 2011 4:39:41 PM
> Subject: Bug fix for $((x**y)) algorithm on 64+ bits machines
On Thu, Dec 02, 2010 at 11:33:24AM -0500, Greg Wooledge wrote:
> On Thu, Dec 02, 2010 at 09:29:29AM -0700, Eric Blake wrote:
> > On 12/02/2010 04:04 AM, Clark J. Wang wrote:
> > > Following command also prints nothing, confused :(
> > >
> > > for ((i = 0; i < 10; ++i)); do echo -n " $i"; done | wh
On Fri, Apr 16, 2010 at 01:22:24AM -0700, Radim wrote:
>
> Hello,
> I have such script:
>
> (ONLY THIS THREE LINES ARE THE COMMANDS )
> content=$(cat $script | sed '/function codecs/,/fi;/d');
> content=$(echo $content | sed -n '/mandriva/,/fi;}/p');
> content=$(echo $content | sed '/^\s*urpmi[
Thanks for heads up, Christian. Filtering out "." will break our company's
accounting software, and presumably many other applications.
Checking for correct charset is sensible thing to do when setting or accessing
a variable. But, those variables that Bash did not change or set, should be
p
y nice editing features of readline can be used for
> updating values already stored in variables. This is extremely useful
> when the value is quite long.
Is this the same as
read -ep "Please correct your name: $NAME" NAME
?
--
William Park <
On Wed, May 31, 2006 at 04:49:36PM -0500, A P Garcia wrote:
> It would be very useful to have a shell option that displays the exit
> code of each command when it terminates.
I'm currently using
PS1='$? [EMAIL PROTECTED]:\w\$ '
$? is what you are after.
--
William P
o ${foo^} ## Convert first character
> Bar
> $ echo ${foo^^} ## Convert all characters
> BAR
> $ echo ${foo^[a-m]} ## Convert first character that matches pattern
> Bar
> $ echo ${foo^^[a-m]} ## Convert all characters that match pattern
> BAr
I did that, and subseq
On Sun, Jan 29, 2006 at 08:16:40PM -0500, Mike Frysinger wrote:
> On Sunday 29 January 2006 20:08, William Park wrote:
> > On Sun, Jan 29, 2006 at 07:33:14PM -0500, Chris F.A. Johnson wrote:
> > > On Sun, 29 Jan 2006, William Park wrote:
> > > >Let's see...
>
On Sun, Jan 29, 2006 at 07:35:32PM -0500, Mike Frysinger wrote:
> On Sunday 29 January 2006 19:23, William Park wrote:
> > Let's see...
> > a-{b{d,e}}-c
> > a-{bd,be}-c
>
> i'm pretty sure the commas are consumed in the expansion
>
> side note,
On Sun, Jan 29, 2006 at 07:33:14PM -0500, Chris F.A. Johnson wrote:
> On Sun, 29 Jan 2006, William Park wrote:
> >Let's see...
> > a-{b{d,e}}-c
> > a-{bd,be}-c
> > a-bd-c a-be-c
> >
> >It looks okey, I think.
>
> Except that
f {a..b}?
This is the only conflict between your standard Bash and my extensions.
If you're keeping it, then I'll change syntax on my end.
--
William Park <[EMAIL PROTECTED]>, Toronto, Canada
ThinFlash: Linux thin-client on USB key (flash) drive
http://home.eol.ca/~parkw
snt
> really matter imo
>
> as you pointed out, the docs say that the brace expansion should only
> happen when commas or sequence expressions are used, and while the
> inner braces used commads, the outer braces did not -mike
Let's see...
a-{b{d,e}}-c
a-{bd,be}-c
> 1)
> let a=(a+500)/1000
> does not work after update from 3.0 to 3.1, while
> let a=\(a+500\)/1000
> is working
You should quote that expression, like
let 'a=...'
>
> 2)
> a=8000; a=$[(a+500)/1000]; ---> 9
Shouldn't that be $((...)) ?
> a=800
mation about the process of submitting patches, no real
> hint of what somebody would have to do to contribute one...
Bash and Readline are written by Chet Ramey. So, give the guy a break.
He's too busy fixing bugs. :-)
--
William Park <[EMAIL PROTECTED]>, Toronto, Canada
ThinF
nd COMp4015, but when it's all capitals, it
> displays it as lowercase. It displays fine on my windows box... Is
> this a bash problem? Is it something else altogether?
It is 'vfat' issue. Try few mounting options. man mount.
--
William Park <[EMAIL PROTECTED]>, Toron
of code), but,
> if you prefer so, then you can download it directly
> from any slackware mirror (for instance,
> from
>
> http://slackware.ngi.it/slackware-10.2/source/a/bash/patches/
> ).
--
William Park <[EMAIL PROTECTED]>, Toronto, Canada
ThinFlash: Linux thin-client on U
, each process communicates with the other via stdin/stdout, and we get the
> actual results via stderr.
Where would you use it?
--
William Park <[EMAIL PROTECTED]>, Toronto, Canada
ThinFlash: Linux thin-client on USB key (flash) drive
http://home.eol
5b/3.0, and I don't get segfault.
--
William Park <[EMAIL PROTECTED]>, Toronto, Canada
ThinFlash: Linux thin-client on USB key (flash) drive
http://home.eol.ca/~parkw/thinflash.html
BashDiff: Super Bash shell
http://freshmeat.net/projects/bashdiff/
__
gt; shell.
>
> I know it worked before in that script and ksh does not make a difference
> between interactive and non-interactive shell. But I don't know
>
> Any comments are welcome.
See if
set -m
makes any difference.
--
William Park <[EMAIL PROTECTED]>, Toront
On Mon, Jul 11, 2005 at 11:57:38AM -0400, William Park wrote:
> Ref:
> http://freshmeat.net/projects/bashdiff/
> http://home.eol.ca/~parkw/index.html#gtk
More updates. The documentation now has some snapshots. The latest
release is BashDiff-1.24.
--
William Park <[EMA
ow build the same thing with
Or,
gtk << EOF
...
EOF
Feedbacks are welcome. Enjoy!
--
William Park <[EMAIL PROTECTED]>, Toronto, Canada
ThinFlash: Linux thin-client on USB key (flash)
CMD_IGNORE_RETURN;
+ exec_result = execute_try_command (command->value.Try);
+ break;
+
case cm_if:
if (ignore_return)
command->value.If->flags |= CMD_IGNORE_RETURN;
@@ -1578,9 +1593,38 @@
SHELL_VAR *old_value = (SHELL_VAR *)NULL; /* Remember the ol
On Sat, Jul 02, 2005 at 11:43:36PM -0400, Chet Ramey wrote:
> Chris F.A. Johnson wrote:
> > On Sat, 2 Jul 2005, William Park wrote:
> >
> >> Dear Chet,
> >>
> >> It would be nice if I can read a file and process it as though it was
> >> here-do
On Sat, Jul 02, 2005 at 05:48:40PM -0600, Bob Proulx wrote:
> Chris F.A. Johnson wrote:
> > William Park wrote:
> > >It would be nice if I can read a file and process it as though it was
> > >here-document text in the script. Mainly, I want variable substitution,
> &
cat <<+ file
cat <<<< file
--
William Park <[EMAIL PROTECTED]>, Toronto, Canada
ThinFlash: Linux thin-client on USB key (flash) drive
http://home.eol.ca/~parkw/thinflash.html
BashDiff: Super Bash shell
http://freshmeat.net/projects/bashdiff/
___
_SUPPORT) Makefile
+ $(RM) pathnames.h
maybe-clean:
-if test "X$(topdir)" != "X$(BUILD_DIR)" ; then \
--
William Park <[EMAIL PROTECTED]>, Toronto, Canada
ThinFlash: Linux thin-client on USB key (flash) drive
http://home.eol.ca/~parkw/thinflash.h
Configuration Information [Automatically generated, do not change]:
Machine: i686
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i686'
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i686-pc-linux-gnu'
-DCONF_VENDOR='pc' -DLOCALEDIR='/usr/local/share/locale' -DPACKA
exits.
>
> This is a classic race condition. It's already been fixed for the
> next version.
Hi Chet,
Can you explain what's happenning with
$( : | : ) &
--
William Park <[EMAIL PROTECTED]>, Toronto, Canada
ThinFlash: Linux thin-client on USB key (flash) drive
Configuration Information [Automatically generated, do not change]:
Machine: i686
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i686'
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i686-pc-linux-gnu'
-DCONF_VENDOR='pc' -DLOCALEDIR='/usr/local/share/locale' -DPACKA
eric argument
>
> I was wondering if BASH requires type conversion? I even printed out
> the values for $val1 and $val2. They look like integers to me. If
> anyone could help me, it would be greatly appreciated.
>
> Thanks in advance
Note the difference between `...` and
t; exit
> else
> echo $1
> echo $2
> echo $3
> echo $4
> echo $5
> echo $6
> echo $7
> echo $8
> echo $9
> echo "$10"
> echo "$11"
> echo "$12"
> fi
Try ${10}
--
William Park <[EMAIL PROTECTED]>, Toronto, Canada
Slackwar
t; read x < foo
> then
> echo ${#x}
> always returns 4 instead of 9 or 10 because it stopped after "asdf" at
> the null char
>
> I've played with setting $IFS, and with -r and -d on the read command
> itself, but nothing seems to work.
>
> Is t
s
~/.xsession
which is usually symlink to ~/.xinitrc, but doesn't have to be. Then,
you're into your windows manager. This initial file is run like any
other shell script on your system.
If you're talking about Xterm, then bring it up as
xterm -ls
--
William Park <[EMA
On Mon, Feb 28, 2005 at 05:28:17PM +0100, Bernd Klein wrote:
> Hi,
>
> I think I found a bug in "sort".
> Maybe this list is not the right place to report it, but I don't know
> where else to do it.
Manpage of 'sort' says,
Report bugs to .
_
Configuration Information [Automatically generated, do not change]:
Machine: i686
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i686'
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i686-pc-linux-gnu'
-DCONF_VENDOR='pc' -DLOCALEDIR='/usr/local/share/locale' -DPACKA
49 matches
Mail list logo