From: gavino
Subject: bash v lisp
Date: 
Message-ID: <333ed381-2516-455d-9253-090426dd6700@e10g2000prf.googlegroups.com>
Hey time for more bash v clisp fun!!!

platform is linux with bash 3 +most recent clisp.

how do I find all the files recursively in directory /something that
are older than 1 minute and newer than 1 day?

Then from that list...how do I place files 2m or smaller into /
something/2mOrLess and rest into /something/2mOrMore ?

From: Jason
Subject: Re: bash v lisp
Date: 
Message-ID: <1f3adb80-bc4c-4130-ac6f-362a4ed6b0ce@h11g2000prf.googlegroups.com>
On Mar 5, 10:36 am, gavino <·········@gmail.com> wrote:
> Hey time for more bash v clisp fun!!!
>
> platform is linux with bash 3 +most recent clisp.
>
> how do I find all the files recursively in directory /something that
> are older than 1 minute and newer than 1 day?
>
> Then from that list...how do I place files 2m or smaller into /
> something/2mOrLess and rest into /something/2mOrMore ?

man find

Here's a hint:

find . -ctime -1 -size -2M | while read fn
do
echo file $fn found
done

Switch the -2M to +2M and do something else. You can even put this
into a script file and use command line args.

-Jason
From: gavino
Subject: Re: bash v lisp
Date: 
Message-ID: <300673a5-9529-4b35-9fce-64e2020e48e8@s13g2000prd.googlegroups.com>
On Mar 5, 11:54 am, Jason <·······@gmail.com> wrote:
> On Mar 5, 10:36 am, gavino <·········@gmail.com> wrote:
>
> > Hey time for more bash v clisp fun!!!
>
> > platform is linux with bash 3 +most recent clisp.
>
> > how do I find all the files recursively in directory /something that
> > are older than 1 minute and newer than 1 day?
>
> > Then from that list...how do I place files 2m or smaller into /
> > something/2mOrLess and rest into /something/2mOrMore ?
>
> man find
>
> Here's a hint:
>
> find . -ctime -1 -size -2M | while read fn
> do
> echo file $fn found
> done
>
> Switch the -2M to +2M and do something else. You can even put this
> into a script file and use command line args.
>
> -Jason

hm but that is not clisp

I am well trained in bash and linux.

The question was howto do that in clisp.
From: Tim Bradshaw
Subject: Re: bash v lisp
Date: 
Message-ID: <45ce094e-5cce-4427-8345-ce926b71e1df@h25g2000hsf.googlegroups.com>
On Mar 5, 8:39 pm, gavino <·········@gmail.com> wrote:

>
> hm but that is not clisp
>

Not only that, it's also catastrophically broken ad exactly an example
of what I was talking about in my other post.
From: Kaz Kylheku
Subject: Re: bash v lisp
Date: 
Message-ID: <d4f4f639-43f8-4e49-86e1-1f73a6cd0131@p73g2000hsd.googlegroups.com>
On Mar 5, 11:54 am, Jason <·······@gmail.com> wrote:
> Here's a hint:
>
> find . -ctime -1 -size -2M | while read fn

That is not bash, strictly speaking. Find is an executable program,
not part of the bash language. (Of course, it could be made into a
bash builtin in the future. But today, it isn't).

To actually do this in current bash, you'd have to code the directory
traversal in bash code.

Look at the sample code that comes with bash, perhaps:

  /usr/share/doc/bash*/functions/recurse

*wink*
From: John
Subject: Re: bash v lisp
Date: 
Message-ID: <ac5cbde5-a434-4213-83f9-6fabcf927bc9@s13g2000prd.googlegroups.com>
On Mar 5, 10:36 am, gavino <·········@gmail.com> wrote:
> Hey time for more bash v clisp fun!!!
>
> platform is linux with bash 3 +most recent clisp.
>
> how do I find all the files recursively in directory /something that
> are older than 1 minute and newer than 1 day?
>
> Then from that list...how do I place files 2m or smaller into /
> something/2mOrLess and rest into /something/2mOrMore ?

The real question is why are you comparing bash and clisp at all? Most
of the real work in whatever sh script you come up with (those who
script in bash instead of bourne shell should be shot) will probably
be done by ls, sed, and maybe awk.
Anyone who uses Lisp for this kind of silly sysadmin task has bigger
problems than "find all files older than x and newer than y".

John
(but feeding trolls is so fun!)
From: gavino
Subject: Re: bash v lisp
Date: 
Message-ID: <8eb73d23-62cf-40e8-8d63-0e69345aeee9@i7g2000prf.googlegroups.com>
On Mar 5, 12:56 pm, John <··········@gmail.com> wrote:
> On Mar 5, 10:36 am, gavino <·········@gmail.com> wrote:
>
> > Hey time for more bash v clisp fun!!!
>
> > platform is linux with bash 3 +most recent clisp.
>
> > how do I find all the files recursively in directory /something that
> > are older than 1 minute and newer than 1 day?
>
> > Then from that list...how do I place files 2m or smaller into /
> > something/2mOrLess and rest into /something/2mOrMore ?
>
> The real question is why are you comparing bash and clisp at all? Most
> of the real work in whatever sh script you come up with (those who
> script in bash instead of bourne shell should be shot) will probably
> be done by ls, sed, and maybe awk.
> Anyone who uses Lisp for this kind of silly sysadmin task has bigger
> problems than "find all files older than x and newer than y".
>
> John
> (but feeding trolls is so fun!)

spanker!
From: gavino
Subject: Re: bash v lisp
Date: 
Message-ID: <725ce59f-f6dd-4d01-8647-46b3d069e23f@u10g2000prn.googlegroups.com>
On Mar 5, 12:56 pm, John <··········@gmail.com> wrote:
> On Mar 5, 10:36 am, gavino <·········@gmail.com> wrote:
>
> > Hey time for more bash v clisp fun!!!
>
> > platform is linux with bash 3 +most recent clisp.
>
> > how do I find all the files recursively in directory /something that
> > are older than 1 minute and newer than 1 day?
>
> > Then from that list...how do I place files 2m or smaller into /
> > something/2mOrLess and rest into /something/2mOrMore ?
>
> The real question is why are you comparing bash and clisp at all? Most
> of the real work in whatever sh script you come up with (those who
> script in bash instead of bourne shell should be shot) will probably
> be done by ls, sed, and maybe awk.
> Anyone who uses Lisp for this kind of silly sysadmin task has bigger
> problems than "find all files older than x and newer than y".
>
> John
> (but feeding trolls is so fun!)

bash > sh what do you mean those who scrpt in bash should be shot? you
phennukk!
From: George Neuner
Subject: Re: bash v lisp
Date: 
Message-ID: <h7aus31k5lu29fe45knt8mi0goc4mf6jeh@4ax.com>
On Wed, 5 Mar 2008 13:34:41 -0800 (PST), gavino <·········@gmail.com>
wrote:

>On Mar 5, 12:56 pm, John <··········@gmail.com> wrote:
>> On Mar 5, 10:36 am, gavino <·········@gmail.com> wrote:
>>
>> > Hey time for more bash v clisp fun!!!
>>
>> > platform is linux with bash 3 +most recent clisp.
>>
>> > how do I find all the files recursively in directory /something that
>> > are older than 1 minute and newer than 1 day?
>>
>> > Then from that list...how do I place files 2m or smaller into /
>> > something/2mOrLess and rest into /something/2mOrMore ?
>>
>> The real question is why are you comparing bash and clisp at all? Most
>> of the real work in whatever sh script you come up with (those who
>> script in bash instead of bourne shell should be shot) will probably
>> be done by ls, sed, and maybe awk.
>> Anyone who uses Lisp for this kind of silly sysadmin task has bigger
>> problems than "find all files older than x and newer than y".
>>
>> John
>> (but feeding trolls is so fun!)
>
>bash > sh what do you mean those who scrpt in bash should be shot? you
>phennukk!

Bourne is the oldest of the currently used Unix shells - every machine
has it.  Bourne scripts can be run in Bash and in the popular Bourne
descendent Dash (Debian Almquist Shell).  Bash scripts can only be run
in Bash.

You call yourself a sysadmin - you should bloody well know this shit
already.

George
--
for email reply remove "/" from address
From: Christopher Koppler
Subject: Re: bash v lisp
Date: 
Message-ID: <f406abbf-8845-4177-887e-d258204c035b@60g2000hsy.googlegroups.com>
On Mar 6, 12:24 am, George Neuner <·········@/comcast.net> wrote:

> You call yourself a sysadmin - you should bloody well know this shit
> already.

He doesn't call himself that, but everyone else calls him troll, so
why should he know? ;)
From: George Neuner
Subject: Re: bash v lisp
Date: 
Message-ID: <anh1t392gcar3gr1g48j6f3b0iigm9uqtj@4ax.com>
On Wed, 5 Mar 2008 23:36:01 -0800 (PST), Christopher Koppler
<········@chello.at> wrote:

>On Mar 6, 12:24 am, George Neuner <·········@/comcast.net> wrote:
>
>> You call yourself a sysadmin - you should bloody well know this shit
>> already.
>
>He doesn't call himself that, but everyone else calls him troll, so
>why should he know? ;)

Actually he does.  Gavino has been posting here for almost 2 years.
Go back and look at his old posts.

George
--
for email reply remove "/" from address
From: Christopher Koppler
Subject: Re: bash v lisp
Date: 
Message-ID: <dfa96bc9-c782-4aa5-adaf-b194b9745cc5@m34g2000hsc.googlegroups.com>
On Mar 7, 5:39 am, George Neuner <·········@/comcast.net> wrote:
> On Wed, 5 Mar 2008 23:36:01 -0800 (PST), Christopher Koppler
>
> <········@chello.at> wrote:
> >On Mar 6, 12:24 am, George Neuner <·········@/comcast.net> wrote:
>
> >> You call yourself a sysadmin - you should bloody well know this shit
> >> already.
>
> >He doesn't call himself that, but everyone else calls him troll, so
> >why should he know? ;)
>
> Actually he does.  Gavino has been posting here for almost 2 years.
> Go back and look at his old posts.

Hoi, you're right! Shame on me for ignoring most gavino posts!
I'll have try to not read them even harder now!
From: Mike G.
Subject: Re: bash v lisp
Date: 
Message-ID: <7d12ab86-0232-4fda-81ae-2b8fdeacacf4@59g2000hsb.googlegroups.com>
On Mar 5, 6:24 pm, George Neuner <·········@/comcast.net> wrote:
> On Wed, 5 Mar 2008 13:34:41 -0800 (PST), gavino <·········@gmail.com>
> wrote:
>
>
>
> >On Mar 5, 12:56 pm, John <··········@gmail.com> wrote:
> >> On Mar 5, 10:36 am, gavino <·········@gmail.com> wrote:
>
> >> > Hey time for more bash v clisp fun!!!
>
> >> > platform is linux with bash 3 +most recent clisp.
>
> >> > how do I find all the files recursively in directory /something that
> >> > are older than 1 minute and newer than 1 day?
>
> >> > Then from that list...how do I place files 2m or smaller into /
> >> > something/2mOrLess and rest into /something/2mOrMore ?
>
> >> The real question is why are you comparing bash and clisp at all? Most
> >> of the real work in whatever sh script you come up with (those who
> >> script in bash instead of bourne shell should be shot) will probably
> >> be done by ls, sed, and maybe awk.
> >> Anyone who uses Lisp for this kind of silly sysadmin task has bigger
> >> problems than "find all files older than x and newer than y".
>
> >> John
> >> (but feeding trolls is so fun!)
>
> >bash > sh what do you mean those who scrpt in bash should be shot? you
> >phennukk!
>
> Bourne is the oldest of the currently used Unix shells - every machine
> has it.  Bourne scripts can be run in Bash and in the popular Bourne
> descendent Dash (Debian Almquist Shell).  Bash scripts can only be run
> in Bash.
>
> You call yourself a sysadmin - you should bloody well know this shit
> already.
>
> George
> --
> for email reply remove "/" from address

By that logic, we should all be writing in Lisp-1 too.

Languages evolve, and so do shells. Shell code is very often for one-
off projects -- why on earth would I concern myself with whether or
not my shell script can be easily back-ported to a PDP-11 running
SysV?

I write in Bourne, except when Bash functionality comes in handy. For
that matter, I write my Lisp code functionally - except when an
imperative construct makes my life easier.

You're clearly an old-time UNIX hacker - us new guys have given up on
your religious wars.

-M
From: George Neuner
Subject: Re: bash v lisp
Date: 
Message-ID: <khe3t3lv8tod10csv4isg09503i1he4s78@4ax.com>
On Fri, 7 Mar 2008 10:37:10 -0800 (PST), "Mike G."
<···············@gmail.com> wrote:

>On Mar 5, 6:24 pm, George Neuner <·········@/comcast.net> wrote:
>> On Wed, 5 Mar 2008 13:34:41 -0800 (PST), gavino <·········@gmail.com>
>> wrote:
>>
>>
>>
>> >On Mar 5, 12:56 pm, John <··········@gmail.com> wrote:
>> >> On Mar 5, 10:36 am, gavino <·········@gmail.com> wrote:
>>
>> >> > Hey time for more bash v clisp fun!!!
>>
>> >> > platform is linux with bash 3 +most recent clisp.
>>
>> >> > how do I find all the files recursively in directory /something that
>> >> > are older than 1 minute and newer than 1 day?
>>
>> >> > Then from that list...how do I place files 2m or smaller into /
>> >> > something/2mOrLess and rest into /something/2mOrMore ?
>>
>> >> The real question is why are you comparing bash and clisp at all? Most
>> >> of the real work in whatever sh script you come up with (those who
>> >> script in bash instead of bourne shell should be shot) will probably
>> >> be done by ls, sed, and maybe awk.
>> >> Anyone who uses Lisp for this kind of silly sysadmin task has bigger
>> >> problems than "find all files older than x and newer than y".
>>
>> >> John
>> >> (but feeding trolls is so fun!)
>>
>> >bash > sh what do you mean those who scrpt in bash should be shot? you
>> >phennukk!
>>
>> Bourne is the oldest of the currently used Unix shells - every machine
>> has it.  Bourne scripts can be run in Bash and in the popular Bourne
>> descendent Dash (Debian Almquist Shell).  Bash scripts can only be run
>> in Bash.
>>
>> You call yourself a sysadmin - you should bloody well know this shit
>> already.
>>
>> George
>> --
>> for email reply remove "/" from address
>
>By that logic, we should all be writing in Lisp-1 too.
>
>Languages evolve, and so do shells. Shell code is very often for one-
>off projects -- why on earth would I concern myself with whether or
>not my shell script can be easily back-ported to a PDP-11 running
>SysV?
>
>I write in Bourne, except when Bash functionality comes in handy. For
>that matter, I write my Lisp code functionally - except when an
>imperative construct makes my life easier.

It makes sense to write to the lowest common denominator whenever the
script is intended to be portable to different systems.  Not everyone
has Korn or csh or Dash or Bash.  But you can absolutely count on
every system having sh.

Ordinarily I agree re: using the best tool, but sometimes it's more
important to play nicely with others.  John was clearly baiting Gavino
with his comment about shooting Bash scripters, but Gavino's
aggravated response clearly indicated to me that he doesn't know when
_not_ to use his pet tools.  That and he's generally a PITA to boot.


>You're clearly an old-time UNIX hacker - us new guys have given up on
>your religious wars.

I'm not that old ;)  and I've never really administered a multiuser
system, only my own workstation(s) and I shared "wheel" responsibility
for a couple of servers in my engineering group.  I just happen to
know the history pretty well.

Most of my development has been for Windows, various RTOSes or bare
metal.  Of Unix systems I've mostly been a user, cross-compiling for
or running simulations of embedded systems.  I have written a
smattering of small X and command line apps - mostly for testing
embedded stuff - but I did long ago write a well received Xenix based
legal billing application, and more recently I collaborated on a Linux
based 3-D diagnostic imaging app (which, unfortunately, is in limbo at
the moment.  I work for an OEM house - the company that commissioned
the app ran out of money during 2nd stage FDA testing.  Hopefully they
will survive, the app will be certified, and y'all will get to see it
used when you inevitably get an MRI/CT/NucMed test).

George
--
for email reply remove "/" from address
From: Dimiter "malkia" Stanev
Subject: Re: bash v lisp
Date: 
Message-ID: <6392i1F25qg3iU1@mid.individual.net>
gavino wrote:
> Hey time for more bash v clisp fun!!!
> 
> platform is linux with bash 3 +most recent clisp.
> 
> how do I find all the files recursively in directory /something that
> are older than 1 minute and newer than 1 day?
> 
> Then from that list...how do I place files 2m or smaller into /
> something/2mOrLess and rest into /something/2mOrMore ?

You can start with something like:

(defun mapdir (dir fn)
   (dolist
       (file (directory (make-pathname :name :wild ;; Stolen from
                                       :type :wild ;; Edi Weitz's
                                       :defaults dir))) ;; start.lisp
     (funcall fn file)
     (when (file-directory-p file)
       (mapdir file fn))))

#+nil
(mapdir "d:/lw/sp/" (lambda (x) (print x)))

#+nil ;; Lispworks specific - system:file-size
(mapdir "d:/lw/sp" (lambda (x) (format t "~A ~A~&" x (system:file-size x))))
From: Dimiter "malkia" Stanev
Subject: Re: bash v lisp
Date: 
Message-ID: <6394e6F26sf0bU1@mid.individual.net>
Version which skips directories, and another one more functional based

(defun mapdir (dir fn)
   (dolist (file (directory
                  (make-pathname :name :wild ;; Stolen from
                                 :type :wild ;; Edi Weitz's
                                 :defaults dir))) ;; start.lisp
     (if (file-directory-p file)
       (mapdir file fn)
       (funcall fn file))))

;; Redefining mapdir just for fun
(defun mapdir (dir fn)
   (mapcar (lambda (file)
             (if (file-directory-p file)
               (mapdir file fn)
               (funcall fn file)))
           (directory
            (make-pathname :name :wild ;; Stolen from
                           :type :wild ;; Edi Weitz's
                           :defaults dir)))) ;;start.lisp

#+nil
(mapdir "d:/lw/sp/" (lambda (x) (print x)))

#+nil ;; Lispworks specific - system:file-size
(mapdir "d:/lw/sp" (lambda (x) (format t "~A ~A~&" x (system:file-size x))))

#+nil ;; Lispworks specific - system:file-size
(mapdir "d:/lw/sp/" (lambda (x) (when (< (* 1024 2048) (system:file-size 
x)) (print x))))


Dimiter "malkia" Stanev wrote:
> gavino wrote:
>> Hey time for more bash v clisp fun!!!
>>
>> platform is linux with bash 3 +most recent clisp.
>>
>> how do I find all the files recursively in directory /something that
>> are older than 1 minute and newer than 1 day?
>>
>> Then from that list...how do I place files 2m or smaller into /
>> something/2mOrLess and rest into /something/2mOrMore ?
> 
> You can start with something like:
> 
> (defun mapdir (dir fn)
>   (dolist
>       (file (directory (make-pathname :name :wild ;; Stolen from
>                                       :type :wild ;; Edi Weitz's
>                                       :defaults dir))) ;; start.lisp
>     (funcall fn file)
>     (when (file-directory-p file)
>       (mapdir file fn))))
> 
> #+nil
> (mapdir "d:/lw/sp/" (lambda (x) (print x)))
> 
> #+nil ;; Lispworks specific - system:file-size
> (mapdir "d:/lw/sp" (lambda (x) (format t "~A ~A~&" x (system:file-size 
> x))))
> 
From: William James
Subject: Re: bash v lisp
Date: 
Message-ID: <23d9de69-55b8-4810-a551-9180e0fe2f60@f47g2000hsd.googlegroups.com>
On Mar 5, 12:36 pm, gavino <·········@gmail.com> wrote:
> Hey time for more bash v clisp fun!!!
>
> platform is linux with bash 3 +most recent clisp.
>
> how do I find all the files recursively in directory /something that
> are older than 1 minute and newer than 1 day?
>
> Then from that list...how do I place files 2m or smaller into /
> something/2mOrLess and rest into /something/2mOrMore ?

Ruby:

dir = "/something"
youngest = 60
oldest = 24 * 60 * 60

file_list = Dir[ "#{ dir }/**/*" ].select{|file|
  (youngest..oldest).include?((Time.now - File.mtime(file))) }

# Put files smaller than 2k in "small"; the rest in "large".
small, large = file_list.partition{|f|
  File.size(f) < 2 * 1024**2 }

p small, large
From: Tim Bradshaw
Subject: Re: bash v lisp
Date: 
Message-ID: <80f33b18-9686-4564-92c3-ba39e8da92cd@q33g2000hsh.googlegroups.com>
On Mar 5, 6:36 pm, gavino <·········@gmail.com> wrote:
> Hey time for more bash v clisp fun!!!
>
> platform is linux with bash 3 +most recent clisp.
>
> how do I find all the files recursively in directory /something that
> are older than 1 minute and newer than 1 day?
>
> Then from that list...how do I place files 2m or smaller into /
> something/2mOrLess and rest into /something/2mOrMore ?

I wonder how many shell scripts people write which claim to do this
actually work in the case of files with interesting names?  I suspect
that essentially none of them do.

(It is easy enough if you can construct a find command to pick out
just the files you care about and use -exec, since there is no
tokenizing going on, but the more typical "find ... | xargs ..." or
"for f in `find ...`" is very very hard to get correct.  I would
always write such things in some other language now.)
From: Dimiter "malkia" Stanev
Subject: Re: bash v lisp
Date: 
Message-ID: <63aroqF25ivktU1@mid.individual.net>
Fun times when you have a file named "-r" or "-R", and you do "rm *" - 
Does this still work the way no one expects?

Tim Bradshaw wrote:
> On Mar 5, 6:36 pm, gavino <·········@gmail.com> wrote:
>> Hey time for more bash v clisp fun!!!
>>
>> platform is linux with bash 3 +most recent clisp.
>>
>> how do I find all the files recursively in directory /something that
>> are older than 1 minute and newer than 1 day?
>>
>> Then from that list...how do I place files 2m or smaller into /
>> something/2mOrLess and rest into /something/2mOrMore ?
> 
> I wonder how many shell scripts people write which claim to do this
> actually work in the case of files with interesting names?  I suspect
> that essentially none of them do.
> 
> (It is easy enough if you can construct a find command to pick out
> just the files you care about and use -exec, since there is no
> tokenizing going on, but the more typical "find ... | xargs ..." or
> "for f in `find ...`" is very very hard to get correct.  I would
> always write such things in some other language now.)
From: Maciej Katafiasz
Subject: Re: bash v lisp
Date: 
Message-ID: <fqpduo$4sn$1@news.net.uni-c.dk>
Den Thu, 06 Mar 2008 10:34:01 -0800 skrev Dimiter \"malkia\" Stanev:

> Fun times when you have a file named "-r" or "-R", and you do "rm *" -
> Does this still work the way no one expects?

Yes, indeed it does. Fun fun fun. So basically what you need to do is to 
create two files, one called -rf, and another called ~, and you have an 
exploit 99.999% shell scripts around fall for.

Cheers,
Maciej
From: Harald Hanche-Olsen
Subject: Re: bash v lisp
Date: 
Message-ID: <pco7igf1ud4.fsf@shuttle.math.ntnu.no>
+ Tim Bradshaw <··········@tfeb.org>:

> On Mar 5, 6:36 pm, gavino <·········@gmail.com> wrote:
> I wonder how many shell scripts people write which claim to do this
> actually work in the case of files with interesting names?  I suspect
> that essentially none of them do.
>
> (It is easy enough if you can construct a find command to pick out
> just the files you care about and use -exec, since there is no
> tokenizing going on, but the more typical "find ... | xargs ..." or
> "for f in `find ...`" is very very hard to get correct.

Which is why you have find ... -print0 | xargs -0 ...

If I ever need to do interesting stuff with the output from a find
command, I typically do something like this, in es (should work the same
in rc, and you can do similar tricks in bash):

  fn-dostuff={for (file=$*) ...}
  find ... -print0 | xargs -0 es -c dostuff

One minor trouble with bash is that the arguments get stuffed into $0,
then $*, so you need to supply a dummy argument for filling up $0.  So
something vaguly like

  find ... -print0 | xargs -0 bash -c 'for x; do blah "$x" ...; done' _

should work, too.

-- 
* Harald Hanche-Olsen     <URL:http://www.math.ntnu.no/~hanche/>
- It is undesirable to believe a proposition
  when there is no ground whatsoever for supposing it is true.
  -- Bertrand Russell
From: Tim Bradshaw
Subject: Re: bash v lisp
Date: 
Message-ID: <c401b3eb-fff6-4f94-90c4-7275314f3853@x41g2000hsb.googlegroups.com>
On Mar 6, 8:16 pm, Harald Hanche-Olsen <······@math.ntnu.no> wrote:

>
> Which is why you have find ... -print0 | xargs -0 ...

When you hsve it, that is.  And while this deals with the tokenisation
issue it doesn't deal with the file-looking-like-a-switch issue.
Again, some systems let you do (say) "rm -- ..." but some don't.  So
if you care about portable code you're in some trouble.

That's what I meant really: yes, you *can* get this stuff right, but
virtually no one does.

--tim
From: Harald Hanche-Olsen
Subject: Re: bash v lisp
Date: 
Message-ID: <pco4pbi3s1v.fsf@shuttle.math.ntnu.no>
+ Tim Bradshaw <··········@tfeb.org>:

> On Mar 6, 8:16 pm, Harald Hanche-Olsen <······@math.ntnu.no> wrote:
>
>>
>> Which is why you have find ... -print0 | xargs -0 ...
>
> When you hsve it, that is.  And while this deals with the tokenisation
> issue it doesn't deal with the file-looking-like-a-switch issue.

Oh sure it does, assuming for example that you run "find . -find args"
... the file named -rf in the current directory comes out of the find
command as ./-rf which no unix command that I know is going to interpret
magically.  But running "find * ..." is of course a bit more dangerous.

> That's what I meant really: yes, you *can* get this stuff right, but
> virtually no one does.

That's a fair argument, all right.  Unix is a bit like a loaded
automatic weapon with the safety off.  Your own feet are not really safe
while you're handling such a weapon, unless you really really know what
you're doing.

-- 
* Harald Hanche-Olsen     <URL:http://www.math.ntnu.no/~hanche/>
- It is undesirable to believe a proposition
  when there is no ground whatsoever for supposing it is true.
  -- Bertrand Russell
From: Tim Bradshaw
Subject: Re: bash v lisp
Date: 
Message-ID: <9001be25-4410-4cad-8e5e-e02c7e4d251c@59g2000hsb.googlegroups.com>
On Mar 8, 1:47 am, Harald Hanche-Olsen <······@math.ntnu.no> wrote:

> Oh sure it does, assuming for example that you run "find . -find args"
> ... the file named -rf in the current directory comes out of the find
> command as ./-rf which no unix command that I know is going to interpret
> magically.  But running "find * ..." is of course a bit more dangerous.

Good point.
From: Tim Bradshaw
Subject: Re: bash v lisp
Date: 
Message-ID: <00f18cd8-89c6-446f-a97d-c9287f0d26d6@u69g2000hse.googlegroups.com>
On Mar 8, 1:47 am, Harald Hanche-Olsen <······@math.ntnu.no> wrote:

> That's a fair argument, all right.  Unix is a bit like a loaded
> automatic weapon with the safety off.  Your own feet are not really safe
> while you're handling such a weapon, unless you really really know what
> you're doing.

I meant to reply to this too, but life got in the way (somehow, skiing
and an exhibition of Ansel Adams prints is more interesting than
computers nowadays, I must be getting old).

I think what is really the problem is shell scripts.  Some people
don't like Unix because of the not-asking-you-if-you-want-to-blow-your-
leg-off thing, but I think that's really fine (see below).

In fact the problem isn't shell scripts, it's languages with
hopelessly deficient evaluation models, of which most Unix shells are
a very good example.  That's why this is still relevant to this
thread, I hope.  Although it might be "easier" to do something in a
shell script, it is probably *harder* to get it actually right.  That
probably doesn't matter to your average Linux person who wants to run
the script once, on a machine they control, so they know nothing bad
is there, and anyway what's the worst that can happen?  A few hours to
rebuild the machine, and time is free, right?

But it *does* matter if you're writing scripts which might be used in
environments you don't control, or on a large number of machines
running n different varieties of the OS, many of which are broken, or
on machines where mistakes might be expensive.  That's what I do, and
I suspect a lot of other people do as well.  And when I stop to think
about it it frightens me.  I'm mostly happy with my scripts, because
I'm the most careful programmer I've ever met, I think (that's
actually why I'm not a programmer any more - careful means slow, and
no-one wants slow programmers).  But I have scripts which map other
scripts, which I often have not written, over hundreds of instances,
including systems and their DR partners.  And my experience of
programmers is such that I have no real confidence that these scripts
are safe, and that worries me (well: I make sure I am not going to be
in the loop when they do blow up, anyway...).

So to go back to the original question: yes, it's easier in sh, but
it's also probably more likely to do something regrettable.  And maybe
it's better not to take that risk.

--tim

Ah yes, the not-asking-you-if-you-want-to-blow-your-leg-off thing.  If
you write programs that do things on substantial numbers of instances,
you *never* want them to ask you stuff, because that's the difference
between something that takes an hour and something that takes months.
The first principle of such things is *never* go interactive: fail
(and report the failure well) if you can't hack it, but do not ask
what you should do.  it is just amazing how many vendors do not
understand this (including vendors of software which only makes sense
when deployed on large estates).