SPUG: How do -aF"\t" in DOS/Windoze?
Tim Maher/CONSULTIX
tim at consultix-inc.com
Tue Jul 17 17:43:44 CDT 2001
SPUGsters,
This is a messed up retread of a forwarded message that makes
it hard to attribute the correct remarks to the appropriate author. 8-{
Suffice it to say that I'm the one doing all the whining and talking
about cheating, and Charles is the one with the friendly, albeit
inadmissable, suggestions 8-}
-Tim Maher
>----- Forwarded message from ced at carios2.ca.boeing.com -----
>On Mon, Jul 16, 2001 at 07:52:11PM -0700, ced at carios2.ca.boeing.com wrote:
>>
>>
>> > And once I get that figured out, I'd like to add the -i option, with it's
>> > own argument, which I can't even make work on Linux:
>>
>> I'm not sure about the quoting issue you're seeing but I don't think
>> -i works with -p or -n since Win32 won't rename a file that's been
>> opened for reading.
>
>|But Perl could work around that, by using a temporary file and
>|renaming it after the reading filehandle has been closed; of course,
>|that doesn't mean it DOES do that, just that it could! 8-}
>
>
>> I can only think of cumbersome workarounds
>> but maybe there's a slick alternative.
>
>|Okay, thanks for your input anyway.
>
>>
>> > # Trying to "shebangify" following one-liner:
>> > /usr/bin/perl -wlnaF' ' -i'.bak' -e 'print "$F[0]\n"'
>>
>> > # Here are some attempts, and their errors (OpenLinux 2.2.18; perl 5.6.0)
>>
>> > #! /usr/bin/perl -wlnaF' ' -i'.bak'
><SNIP>
>
>> > Can somebody please tell me the correct syntax to a) on Linux, include
>> > two options on the shebang line that require corresponding arguments,
>> > that might need quoting, and b) on Dos/Windoze, supply a non-printing
>> > ( <TAB> ) or special ( \t) character as the argument of -F.
>> >
>>
>> Dang, I don't have Linux/bash handy but the following worked on
>> Solaris/ksh.
>>
>> #!/usr/bin/perl -lawn -i.bak -F\t
>
>|With some OS environments, like Solaris/ksh, you're free to provide
>|multiple arguments to the command interpreter, but with others
>|(like Linux/Bash) you've got to squish them all together, which creates
>|challenging parsing problems when you've got two options like -F and -i
>|that each need attached arguments! 8-{
>
>| Tim found this on the bash man page:
>|
>| If the program is a file beginning with #!, the remainder
>| of the first line specifies an interpreter for the pro
>| gram. The shell executes the specified interpreter on
>| operating systems that do not handle this executable for
>| mat themselves. The arguments to the interpreter consist
>| of a single optional argument following the interpreter
>| ^^^^^^^^^^^^^^^^^^^^^^^^^
>| name on the first line of the program, followed by the
>| name of the program, followed by the command arguments, if
>| any.
>>
>> (I noticed though the -a pattern will split on whitespace exactly
>> like split " " though so the alternate field specifier shouldn't
>> be necessary though in one of the cases above)
>
>|But that's cheating; I was just using <SP> as the separator to simply
>|illustrate the problem; in reality, I want to find a syntax that will allow
>|me to use any arbitrary delimiters, using specifications like -aF'[,:-]+' .
>
>|Any DOS Perlers out there who can tell me what shebang-lines are possible
>|in that wacky world?
>
>I tried moving some (well, all of 'em actually) of the options to the
>command line, e.g.,
>
>perl -lawn -F'xyz\s+delimit' -i.bak file.pl input.txt
>
>Everything now works charmingly. But, that's not what you want so maybe
>the DOS'ers can decipher what's happening.
>--
>Charles DeRykus
That's cheating too! 8-} I'm trying to find a way to supply all
the invocation options on the shebang line, without DOS/Windoze freaking
out about syntax errors. I'm surprised that this is turning out to be
so difficult! And now that I've delved into this a bit (and strayed from
my usual Korn shell), I've realized that
even under the Bash shell on Linux, you're restricted to a single option
argument on the shebang line. How can you ever supply two options with
corresponding arguments with this limitation? 8-{ As in
#! /usr/bin/perl -wlnaF':' -i'orig_*'
This doesn't work with Bash on Linux, or Win95 command.com,
and of course, neither does this:
#! /usr/bin/perl -wlnaF:iorig_*
(How could the F option be expected to know where its argument ends?)
Must I resort to writing a special wrapper that deciphers the shebang-line
options and then invokes perl with separated arguments? Seems like there
ought to be a better way to handle this, wouldn't you think?
*=========================================================================*
| Dr. Tim Maher, CEO, Consultix (206) 781-UNIX/8649; ask for FAX# |
| Email: tim at consultix-inc.com Web: http://www.consultix-inc.com |
| TIM MAHER: Unix/Perl DAMIAN CONWAY: Adv. Perl COLIN MEYER: Perl/DBI |
| CLASSES-> Minimal Perl: 9/17; Perl+Mods: 9/18; UNIX: 9/24; Shell: 10/8 |
*=========================================================================*
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
POST TO: spug-list at pm.org PROBLEMS: owner-spug-list at pm.org
Subscriptions; Email to majordomo at pm.org: ACTION LIST EMAIL
Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest
Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/
More information about the spug-list
mailing list