perl does not treat # inside `` properly 
Author Message
 perl does not treat # inside `` properly

The perl language is supposed to provide shell syntax equivalence
within the `` characters. However I have seen that the # character
even within `` is not treated equivalently. e.g.


world           -a .
CVSROOT         -i mkmodules CVSROOT
modules         -i mkmodules CVSROOT modules
loginfo         -i mkmodules CVSROOT loginfo
commitinfo      -i mkmodules CVSROOT commitinfo
rcsinfo         -i mkmodules CVSROOT rcsinfo
editinfo        -i mkmodules CVSROOT editinfo
testmod -a testdir/new
bigmod -a testdir/new2

However within perl the same thing does not work :
  DB<11> p `cat $cvsroot/CVSROOT/modules |grep - | grep -v #`

  DB<12> p `cat $cvsroot/CVSROOT/modules |grep -`
    #       key     -a    aliases...
    #       -i prog         Run "prog" on "cvs commit" from top-level of module.
    #       -o prog         Run "prog" on "cvs checkout" of module.
    #       -t prog         Run "prog" on "cvs rtag" of module.
    #       -u prog         Run "prog" on "cvs update" of module.
    #       -d dir          Place module in directory "dir" instead of module name.
    #       -l              Top-level directory only -- do not recurse.
    # The "-a" option specifies an alias.  An alias is interpreted as if
    # everything on the right of the "-a" had been typed on the command line.
    world           -a .
    CVSROOT         -i mkmodules CVSROOT
    modules         -i mkmodules CVSROOT modules
    loginfo         -i mkmodules CVSROOT loginfo
    commitinfo      -i mkmodules CVSROOT commitinfo
    rcsinfo         -i mkmodules CVSROOT rcsinfo
    editinfo        -i mkmodules CVSROOT editinfo
    testmod -a testdir/new
    bigmod -a testdir/new2



Sun, 05 Mar 1995 01:52:29 GMT  
 perl does not treat # inside `` properly
:
: The perl language is supposed to provide shell syntax equivalence
: within the `` characters.

More specifically, it's supposed to provide Bourne shell syntax equivalence.

: However I have seen that the # character
: even within `` is not treated equivalently. e.g.

Perl has nothing to do with that.  You'd have the same problem with
that command in a shell script.  You're getting away with it on the
command line because when the Berkeley hacked in '#' as a comment
character in csh, they disabled that feature when the the shell was
running interactively.  Neither Bourne shell nor csh let you get away
with that when running non-interactively.

Try the following:

    Running sh
        $ echo hi # there
        hi
        $

    Running csh interactively

        % echo hi # there
        hi # there
        %

    Running csh non-interactively

        % echo "echo hi # there" >/tmp/foo
        % csh /tmp/foo
        hi
        %

Bourne shell is a MUCH more consistent beastie than csh.  All
reasonable C implementations of system() and popen() call out to
/bin/sh.  So do some unreasonable ones, like Perl.  :-)

Larry



Sat, 11 Mar 1995 06:54:49 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Doing a `` with a timeout?

2. DBI - 0 is not being treated as False ?

3. eval in Perl is not acting properly

4. Perl system command and NT not executing properly...

5. Perl not handling tty I/O properly?

6. split inside split - can it be done ?

7. Perl system command and NT not executing properly...

8. Active Perl on Win 98 not exiting properly

9. Perl system command and NT not executing properly...

10. perl/tk does not handle button events properly

11. What can and should not be done in Perl

12. Perl code not doing what I expected

 

 
Powered by phpBB® Forum Software