Re: internal alias
- From: bsh <brian_hiles@xxxxxxxxxxxxxx>
- Date: Wed, 23 Jan 2008 18:43:21 -0800 (PST)
<rea...@xxxxxxxxxxx> wrote:
bsh <brian_hi...@xxxxxxxxxxxxxx> writes:
...
It will probably start a religious war but I'm kind of curious what
you have in mind. I suspect it will be pretty much outside of my
usage though since my skill are pretty low level.
You're asking my opinion? Oh, bad, bad idea! ;)
Not sure when that happened but I think its kind of new. I haven't
really used bash for a good while, except for actual shell. All shell
scripting was in ksh.
I liked ksh93 for the regex matching.. like having awk in your shell
script without calling it. I did not realize that bash now possesses
that skill too ... the =~ operator.
Oh, you have no idea! Expanded Regular Expressions *slash* Globbing
syntax has been quite enhanced since its inception in ksh88.
For instance (and I know that at your usage level you will probably
not even need to use it):
$ var=${var#~(E).*[[:space:][:blank:]]} # "~(E)" is new
Besides the new parameters .sh.edchar, .sh.edmode, .sh.edcol,
..sh.edtext, and .sh.version, which have been documented well enough
(if underutilized), there now there are are many more (and it's
about time):
..sh.match[] : The most recent match and sub-pattern matches
substrings.
..sh.file : The pathname of the file than contains the current
command.
..sh.fun : The name of the current function that is being executed.
..sh.subshell : The current depth for subshells and command
substitution.
..sh.name : script script name
..sh.fun : current function name
..sh.subscript
..sh.value
The new printf %T directive makes all the usual C.U.S. date-time
queries ("last day in month...?", "how many days between...?",
"julian day number of...?") now officially obsolete. It even has
a simple natural language interface:
$ printf '%(%Y-%m-%dT%H:%MZ)T' 'day before yesterday'
There are a few new operators for here-documents:
<<<word : A short form of here-document in which <word> becomes the
contents of the here-document after any parameter expansion, command
substitution, and arithmetic substitution occur.
.... and byte offsets for file descriptors:
<# ((expr)) : In addition, $(n<#) expands to the current byte offset
for file descriptor n. (ksh93r+)
# ((expr)) : In addition, $(n<#) expands to the current byte offset for file descriptor n. (ksh93r+)"SEEK_HOLE", "EOF", and "HOLE" are substitutable parameters.
You didn't know that ksh(1) is an object-oriented language? ksh93
has always had it... via an unreleased library (typeset -T) :(
https://mailman.research.att.com/pipermail/ast-developers/2004q3/000082.html
.... Nested variables too, upon which its O.O. is based:
$ food=(
[meat]=(
integer quantity=100
float price=10.40
)
[milk]=(
integer quantity=100
float price=2.05
)
)
$ print ${food[meat].price}
10.40
(Now, if only ksh builtin networking (/dev/@(tcp|udp)/) was
correctly compiled on every Unix host!....)
With the AST (AT&T Software Toolkit) library included with
ksh93, threads have always been available (coshell), and much,
much more: The ksh93 toolkit comes with a script compiler
(shcomp), a cscope-like relational database via the Kornshell
Information Abstraction (KIA) database produced by the undocumented
-D option and browsed by freely available GUI and TUI browsers
(ciao/cql), and a profiler: pfksh, rpfksh, or via script:
"profiler.ksh93"
https://mailman.research.att.com/pipermail/ast-users/2006q3/001357.html
(I wrote one too; mine's better!)
I'm starting to think I might be smarter to just go with bash. At my
usage level its very close.
Yes, I'm a ksh93 advocate, but my criticism of bash(1),
despite all the above, has nothing intrinsically to do with
just an enumeration of features. I'm a practical person, and
understand 80% of programmers use 20% of available features
of a language. Indeed, the ubiquity of open-source bash
(before the ksh sourcebase was made available) was and is
an invaluable contribution to the Unix community.
What I do decry is a language that subjugates design elegance
to mere "featuritis", codified by this old language designer's
Three Laws of Language Design, thus:
(1) What _should_ work, _must_ work!
(2) Provide _functionality_, not _features_, at well-defined
levels of abstraction.
(3) In context of the above, the language designer must never,
_ever_ tell the programmer what s/he can or can't do!
That is to say, k/sh (and bash) is and should never become a
perl/python/ruby. Its design was an almost foreordained reflection
of the Unix API, wherein shell's very-high-level abstraction of
redirection and pipes so well explicates the design elegance of
Unix. I respect the job that DGK has done in maintaining and
extending ksh, as much for the features that he _hasn't_ implemented
as the ones he has. All this extra kruft is what dynamic loading of
shared libraries (builtin -f) are for.
For instance, I think I've discovered a way to turn any script --
without modification! -- into a host-independent GUI. Stay tuned!
Ksh(1) is not completely innocent -- its early versions were
buggy messes, and the newest features are currently under-
documented... or not documented at all. Indeed, my major grievance
with ksh93 is that the latest features have been for me documented
only "accidentally" by reading the developers' forums or the
changelogs. *Grrr!*
By way of anecdote, long ago I emailed Chet Ramey (bash author) and
asked that he correctly emulate a facet of sh(1) that had been
implemented (and documented!) since version 7 Unix -- it was
breaking all of my scripts! He replied that it was original a
misfeature (wrong: I worked with Bill Joy at Berkeley), was not
used or important (what!?). He suggested I use the --posix option
to get the requested effect (not default), and that I was being
"disingenuous." *Sigh.* He just doesn't "get it."
A restatement to this effect can be seen on a past thread:
http://groups.google.com/group/comp.unix.shell/browse_thread/thread/41117551288a55fa/4e4cf34fc5c9e99e?lnk=st&q=#4e4cf34fc5c9e99e
My apologies for "going off" like this, and for getting somewhat
off topic.
=Brian
.
- References:
- internal alias
- From: reader
- Re: internal alias
- From: bsh
- Re: internal alias
- From: reader
- internal alias
- Prev by Date: Re: command substitution error using bash
- Next by Date: Variable expansion issue
- Previous by thread: Re: internal alias
- Next by thread: Pattern matching question
- Index(es):
Relevant Pages
|