Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

OT: Re: command-line vs. script file

Chris F.A. Johnson wrote:
> On Sun, 15 May 2005 at 13:21 GMT, Ed Morton wrote:
> 
>
>
>     There's nothing wrong with "-" in a filename, except at the
>     beginning.

Any time you have to say "except..." there is a problem.

The POSIX portable filename standard allows letters,
>     numbers, periods, hyphens and underscores, but a name may not
>     begin with a hyphen.
>

We often write scripts that manipulate file names, holding parts of the
name in variables, creating tmp file names from the parts, etc. so the
impact of a hyphen isn't restricted to where it appears in the original
file name.

I agree you can later code to avoid the potential problems introduced by
"-"s, but if you just choose to avoid them when creating the files then
you don't need to deal with them at all.

Ed

Report this thread to moderator Post Follow-up to this message
Old Post
Ed Morton
05-18-05 08:57 AM


Re: OT: Re: command-line vs. script file
In article <ta6dnY-rs8WWHRrfRVn-1w@comcast.com>,
Ed Morton  <morton@lsupcaemnt.com> wrote:
...
>We often write scripts that manipulate file names, holding parts of the
>name in variables, creating tmp file names from the parts, etc. so the
>impact of a hyphen isn't restricted to where it appears in the original
>file name.

Exactly.  That's the point.


Report this thread to moderator Post Follow-up to this message
Old Post
Kenny McCormack
05-18-05 08:57 AM


Re: OT: Re: command-line vs. script file
On Sun, 15 May 2005 at 16:59 GMT, Ed Morton wrote:
>
>
> Chris F.A. Johnson wrote: 
>
> Any time you have to say "except..." there is a problem.
>
> The POSIX portable filename standard allows letters, 
>
> We often write scripts that manipulate file names, holding parts of the
> name in variables, creating tmp file names from the parts, etc. so the
> impact of a hyphen isn't restricted to where it appears in the original
> file name.
>
> I agree you can later code to avoid the potential problems introduced by
> "-"s, but if you just choose to avoid them when creating the files then
> you don't need to deal with them at all.

When is a hyphen a problem, except at the beginning of a
filename?

--
Chris F.A. Johnson                     <http://cfaj.freeshell.org>
 ========================================
==========================
Shell Scripting Recipes: A Problem-Solution Approach, 2005, Apress
<http://www.torfree.net/~chris/books/ssr.html>

Report this thread to moderator Post Follow-up to this message
Old Post
Chris F.A. Johnson
05-18-05 08:57 AM


Re: OT: Re: command-line vs. script file

Chris F.A. Johnson wrote:
> On Sun, 15 May 2005 at 16:59 GMT, Ed Morton wrote:
> 
>
>
>      When is a hyphen a problem, except at the beginning of a
>      filename?
>

As a trivial example:

$ file=a-b
$ tmp="${file#[a-z]}"
$ > $tmp
$ rm $tmp
rm: invalid option -- b
Try `rm --help' for more information.

Had I instead used underscores in the name of "file":

$ file=a_b
$ tmp="${file#[a-z]}"
$ > $tmp
$ rm $tmp

The hyphen was not at the start of the original file name but by
manipulation to produce a tmp file, it ended up at the front of the tmp
file name and so became a problem.

Regards,

Ed.

Report this thread to moderator Post Follow-up to this message
Old Post
Ed Morton
05-18-05 08:57 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

AWK archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 09:59 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.