|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Nicolas Alvarez wrote:
>> ["This makes it read from a file. Unless the file is named '-', in
>> which case it reads from stdin." OK, so how do I make it read from a
>> file that's actually named '-' then? And other surprising ad-hoc
>> behaviours...]
>
> ./-
OK. But it now means that if you write a script that does this, you need
to explicitly check whether the file you're going to process just
happens to be called "-" and manually escape it if it is. And just
think, if you didn't realise that, your script might be used for *years*
before somebody tries to use it in that specific way and makes it crash
spectacularly.
Urg. Anyways...
--
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
> Nicolas Alvarez wrote:
>>> ["This makes it read from a file. Unless the file is named '-', in
>>> which case it reads from stdin." OK, so how do I make it read from a
>>> file that's actually named '-' then? And other surprising ad-hoc
>>> behaviours...]
>>
>> ./-
>
> OK. But it now means that if you write a script that does this, you need
> to explicitly check whether the file you're going to process just
> happens to be called "-" and manually escape it if it is. And just
> think, if you didn't realise that, your script might be used for *years*
> before somebody tries to use it in that specific way and makes it crash
> spectacularly.
1. If the file is called -, you're calling for trouble anyway.
2. Whoever passes a filename to your script should be using the ./- thing.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Orchid XP v7 <voi### [at] devnull> wrote:
> > I love the Unix philosophy of making specific, lightweight tools that
> > interoperate, rather than gargantuan monolithic beasts that do
> > everything rather poorly.
> See, now, personally I hate that. It annoys the hell out of me that the
> Unix way is to use 50,000 tiny tools with all have far too many
> backwards compatibility modes, bugs and "features".
He was talking about the unix philosophy, not how this philosophy has
been implemented in some environments.
--
- Warp
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Nicolas Alvarez <nic### [at] gmailisthebestcom> wrote:
> 1. If the file is called -, you're calling for trouble anyway.
> 2. Whoever passes a filename to your script should be using the ./- thing.
Many shellscripts break with file names with spaces in them. This is
because surprisingly few unix geeks know that in shell scripts you have
to use "$@" to refer to all the command-line arguments, not $*.
--
- Warp
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Warp wrote:
> Nicolas Alvarez <nic### [at] gmailisthebestcom> wrote:
>> 1. If the file is called -, you're calling for trouble anyway.
>
>> 2. Whoever passes a filename to your script should be using the ./- thing.
>
> Many shellscripts break with file names with spaces in them.
Actually, it's worse. There are surprisingly few utilities that don't
break on *any* possible file name.
Here's a contest. Given the directory /tmp/stuff, delete all the files
in that directory that end with ".tmp".
Let's see how many iterations it takes to get actually right.
--
Darren New / San Diego, CA, USA (PST)
"That's pretty. Where's that?"
"It's the Age of Channelwood."
"We should go there on vacation some time."
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
> Here's a contest. Given the directory /tmp/stuff, delete all the files
> in that directory that end with ".tmp".
>
> Let's see how many iterations it takes to get actually right.
Then I guess rm /tmp/stuff/*.tmp isn't good enough? :)
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Nicolas Alvarez wrote:
>> Here's a contest. Given the directory /tmp/stuff, delete all the files
>> in that directory that end with ".tmp".
>>
>> Let's see how many iterations it takes to get actually right.
>
> Then I guess rm /tmp/stuff/*.tmp isn't good enough? :)
That doesn't even work if there *aren't* funky characters in the file name.
--
Darren New / San Diego, CA, USA (PST)
"That's pretty. Where's that?"
"It's the Age of Channelwood."
"We should go there on vacation some time."
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Darren New <dne### [at] sanrrcom> wrote:
> Nicolas Alvarez wrote:
> >> Here's a contest. Given the directory /tmp/stuff, delete all the files
> >> in that directory that end with ".tmp".
> >>
> >> Let's see how many iterations it takes to get actually right.
> >
> > Then I guess rm /tmp/stuff/*.tmp isn't good enough? :)
> That doesn't even work if there *aren't* funky characters in the file name.
It *does* work, assuming you have a sufficiently modern shell (and not
a 20 years old sh). Modern shells are rather smart at escaping what needs
to be escaped when you write "*".
--
- Warp
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Warp wrote:
> Darren New <dne### [at] sanrrcom> wrote:
>> Nicolas Alvarez wrote:
>>>> Here's a contest. Given the directory /tmp/stuff, delete all the files
>>>> in that directory that end with ".tmp".
>>>>
>>>> Let's see how many iterations it takes to get actually right.
>>> Then I guess rm /tmp/stuff/*.tmp isn't good enough? :)
>
>> That doesn't even work if there *aren't* funky characters in the file name.
>
> It *does* work, assuming you have a sufficiently modern shell (and not
> a 20 years old sh). Modern shells are rather smart at escaping what needs
> to be escaped when you write "*".
Bull. Put 300,000 files to be deleted in /tmp/stuff, and watch it bomb.
--
Darren New / San Diego, CA, USA (PST)
"That's pretty. Where's that?"
"It's the Age of Channelwood."
"We should go there on vacation some time."
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Orchid XP v7 wrote:
>> I love the Unix philosophy of making specific, lightweight tools that
>> interoperate, rather than gargantuan monolithic beasts that do
>> everything rather poorly.
>
> See, now, personally I hate that. It annoys the hell out of me that the
> Unix way is to use 50,000 tiny tools with all have far too many
> backwards compatibility modes, bugs and "features".
So what you're really saying, is that we need a modern implementation of
traditional Unix style tools, distributed as a package. It wouldn't
need a ton of that backwards-compatibility stuff, because all of the
included tools are fresh implementations that we know work together.
--
...Ben Chambers
www.pacificwebguy.com
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |