Re: Request for Comments -- shell features and documentation
From: Stephane CHAZELAS (this.address_at_is.invalid)
Date: 06/17/04
- Next message: Al Sponsor: "bash/sed problem"
- Previous message: Kenny McCormack: "Re: how to delete several lines in a file"
- In reply to: William Park: "Request for Comments -- shell features and documentation"
- Next in thread: William Park: "Re: Request for Comments -- shell features and documentation"
- Reply: William Park: "Re: Request for Comments -- shell features and documentation"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 17 Jun 2004 17:52:19 GMT
2004-06-16, 18:45(+00), William Park:
> As you know, I've been adding to Bash many useful features from Awk,
> Python, Zsh, and Ksh, and other things that you probably never heard of.
[...]
I've seen your announces for your various patches. I didn't feel
much concerned as I'm not a bash user and most of the added
features have counterparts in zsh anyway.
Some comments:
[...]
> for i in ../bash205b-00{1,2,3,4,5,6,7}; do
> patch -p0 < $i
> done
Or:
cat ../bash205b-00[1-7] | patch -p0
> patch -p1 < ../bash.diff
> CFLAGS="-DPATTERN_MATCHING" ./configure
Dependency for gdbm is not checked. Why not use
sleepycat/Berkeley DB instead of gdbm?
My opinion is that $BASH_VERSION should reflect the fact that
it's not the official bash.
> {int..int} or {string--string}: {a..b} or {a--b}
> For {a..b}, generate integer sequence from 'a' to 'b'
> inclusive, using either {a,a+1,...,b-1,b} or
> {a,a-1,...,b+1,b}. If 'a' or 'b' has leading 0, then zero
> pad the numbers. The format size is the maximum size of
> 'a'
> or 'b'. Eg.
> {1..5} --> {1,2,3,4,5}
> {05..01} --> {05,04,03,02,01}
>
> If 'a' or 'b' is a regular shell variable (not positional
> parameter or array element), then replace it with its
> value $a or $b. If 'a' or 'b' starts with '!', then
> indirect substitution will be tried, similiar to ${!a} or
> ${!b}. If 'a' or 'b' is '#', then replace it with $#. In
> any case, if the final 'a..b' is pure number, then
> generate the corresponding integer sequence. Eg.
It would have been much simpler (and more consistent with
{$a,$b}) to allow for {$a..$b}.
{1..6,8..15} may have been useful too (it's not implemented in
zsh either).
[...]
> $(.. string): $(.. string) or `.. string`
> If command substitution string begins with '..', then the
> rest of string is sent to Awk as
> awk "BEGIN{string}"
> after escaping any double quotes. Since the string is
> within double quote, the usual shell expansions are done,
> enabling you to use shell variables. This is intended for
> one-liner floating point math, ie.
> a=1.2
> b=$(.. print $a * 3.4)
> but any Awk code can be given.
>
> * help [[
Not very useful to my mind. Quoting and escaping may reveal
confusing in the end. A function would have been enough.
__() {
local IFS=" "
command -p awk "BEGIN{$*}"
}
... $(__ "awk script")
Why ".." for "awk"?
Note that it hangs on Solaris and the awk you get depends on
PATH.
I can't manage to run the
print "\""
awk script. What should the quoting be?
> [[ ... ]]: [[ expression ]]
> If you compile with -DPATTERN_MATCHING, then '=~' and '!~'
> operators do regular expression matching, via builtin
> command 'match'. Like glob matching with '==' and '!=',
> LHS is string and RHS is regex, ie.
> string =~ regex
> string !~ regex
>
> These regex conditional tests are available in '[..]',
> '[[...]]', and 'test' builtin.
>
> * help match
That one is useful. Escaping should be documented.
There's no way to use a variable as litteral string in the
pattern (no distinction between quoted and unquoted variables as
in shell pattern matching).
[...]
> case: case WORD in [PATTERN [| PATTERN]...) COMMANDS ;;]... esac
> If PATTERN begins and ends in matching quote (ie. '...' or
> "..."), then regular expression matching is done via
> builtin 'match'. Quotes are removed in the same manner as
> here document delimiter. Only the first and the last
> characters are tested, so you can have
> case ... in
> ''something'') ... ;;
> "some""thing") ... ;;
> esac
Not backward compatible.
bash-2.05b$ case a in "$a") echo Y;; esac
bash: `$a': illegal regex in regcomp()
zsh: segmentation fault (core dumped) ./bash
bash-2.05b$ [[ a =~ '$a' ]]
bash: [[: `$a': illegal regex in regcomp()
zsh: segmentation fault (core dumped) ./bash
-- Stephane
- Next message: Al Sponsor: "bash/sed problem"
- Previous message: Kenny McCormack: "Re: how to delete several lines in a file"
- In reply to: William Park: "Request for Comments -- shell features and documentation"
- Next in thread: William Park: "Re: Request for Comments -- shell features and documentation"
- Reply: William Park: "Re: Request for Comments -- shell features and documentation"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|