bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: give me some syntax sugar, honey!


From: Paul Jarc
Subject: Re: give me some syntax sugar, honey!
Date: Sat, 10 Nov 2001 01:22:42 -0500
User-agent: Gnus/5.090004 (Oort Gnus v0.04) Emacs/20.7 (i386-redhat-linux-gnu)

Stig Zax Hackvän <address@hidden> wrote:
> On Fri, Nov 09, 2001 at 12:23:11PM -0500, Paul Jarc wrote:
>> The [] syntax already has meaning, so it shouldn't be changed.
>
> [N-M] has meaning, but [NN-MM] does not.

Yes, it does.  [ab-yz] matches "a", any character between "b" and "y"
inclusive, and "z".  Look for "Pattern Matching" in the man page for
more info.

> similarly, [12-17,19-21,33] is an intuitive shorthand for {[12-17],[19-21],33}

That particular pattern does not have a defined meaning, but only
because the ranges [2-1] and [9-2] are backwards.  The general
suggestion would change the meaning of existing meaningful constructs.

>> eval "echo foo{$(seq -s, 12 21)}"
>
> that's a clever shell hack, but it's no good for typing on a regular basis.

That's what aliases and shell functions are for.

expand() {
  local command="$1" prefix="$2" first="$3" last="$4"
  eval "$command $prefix{$(seq -s, "$first" "$last")}"
}
expand echo foo 12 21

>     Perl is a language for getting your job done.
>
>     Of course, if your job is programming, you can get your job done with any
>     "complete" computer language, theoretically speaking.  But we know from
>     experience that computer languages differ not so much in what they make
>     POSSIBLE, but in what they make EASY.

Well, Perl certainly makes mistakes easy.


paul



reply via email to

[Prev in Thread] Current Thread [Next in Thread]