Dennis Williamson wrote:
On Mon, Aug 15, 2011 at 10:19 PM, Linda Walsh <b...@tlinx.org> wrote:
How do I determine the location of my script?
http://mywiki.wooledge.org/BashFAQ/028
??? I don't understand the need for complexity -- what I have works. Its a
few
lines@ most -- I use the same in perl. has worked for years. But then I'm
not running
the scripts on remote systems via 'ssh'....
I don't need to fix problems that aren't broken.
The "don't do that" messages in Greg's FAQs are just as important, if
not more so, as the "how to" stuff.
----
Who's Greg? I mean before some days ago and other than seeing the
name on
this list, who is he from Adam that someone should think his FAQ is
important?
I don't know the name other than from seeing it this list (not sure if
others or not).
That said, I hope you understand that you put the "donot messages"
into the
same importance level as the "how to" stuff -- which I ask -- why is it
that it
is important (I don't know -- previous maintain of bash? Head of some
Gnu org?
He's not Stallman, and other than him, I don't know if I've personally
me any
of the other gnu people...
Even apart from my ignorance, there are some known problems with his
knowledge
base. 1) an extremely noticeable bias against "-e", to the point that
attempts by other
people to see it "fixed"" and made useful are met with, at least,
resistance, if not
some irritation.
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 "<<<"
syntax (which
can be derived from his "<<" examples, but he totally doesn't talk about
b=0
a=b
(($a=32)
echo $b
32
Only mentioning these items as have already mentioned them directly ...
there
are other problems with his knowledge base that make me only likely to
accept his
information in the context it was given -- but not for every purpose.
Of course if he
believe to speak for every purpose, then more power to him, but let's
not speak,
sideways, thusly! instead ...the below:
[1]prefix="snapdir/@GMT-"
[2]snap_today="$(date +%Y.%m.%d-)"
[3]snap_prefix="$mp/$prefix$snap_today*"
[4]today_snaps="$('ls' -1 ${snap_prefix} 2>/dev/null |tr "\n" " " )"
This one is so bad, I saved it for last. Ack! Pfffft! Wait, what? Why?
What the? Huh?
I don't see any globbing unless it comes in via an argument to that
script.
I put numbers on the lines above, for reference, see the definition
of ${snap_prefix} on line [3]...note the end of the line has
a "*" on it.
At the end of line 3, with mp=/home, and date=today, 08/16, snap_prefix
will have the value:
/home/snapdir/@GMT-2011.08.16*
Inside the $() in #4, as ${snap_prefix} is NOT in quotes, the shell
will expand the * if possible to match any filesnames starting with
that prefix...i.e. the purpose is to look and see if there have been
snaps created 'today'...that searches for them with "time" as
a w
/home/snapdir/@GMT-2011.08.16*
Why do you need it in a list? The only thing you're doing with
that variable is checking to see if the files exist. Please see
http://mywiki.wooledge.org/BashFAQ/004
Why are there single quotes around ls?
===
So it doesn't invoke any aliases for 'ls'... -- my bashrc has "ls -CF",
so it puts
ID chars on the end...
so when I ran that code, I got back "xxyz/" which I wasn't expecting,
so 'ls' makes sure it does a path search for it....