"Tanton Gibbs" <[EMAIL PROTECTED]> wrote in message
019201c1c610$decae5e0$81486e0a@brooklyn">news:019201c1c610$decae5e0$81486e0a@brooklyn...
> I'm running perl on cygwin and trying to do the following one liner:
>
> perl -pi -e 'BEGIN{$pwd=`pwd`;} s/^HOME=.*/HOME=$pwd/;' makeinclude
>
> which will replace the line
> HOME=/home/whoever
> with
> HOME=(whever I happen to be at the moment)
> in my makinclude file
>
> However, cygwin apparently does not like that and will just delete
> makinclude.  cygwin apparently only works when you supply a suffix to i
> perl -pi.bak -e ...

Cygwin uses ActiveState perl. This is a known bug, Bug 19116, can be found
on the ActiveState site.

You should chomp the pwd to get rid of the \n
          chomp($pwd = `pwd`)
 and
do this in your regex
        s/^(HOME\=)(.*?)$/$1$pwd/g
 to keep "HOME="

perl -pi.bak -e "chomp($pwd=`pwd`); s/^(HOME\=)(.*?)$/$1$pwd/g;"

I got an error message running your one-liner, so I swapped the single
quotes for doubles and visa versa. Unlink doesn't seem to work from this
either. I understand you consternation on the backup file but it could save
you in the event of a mistake.
>
> But I don't want a backup made of the file, so I have to unlink it
>
> perl -pi.bak -e 'BEGIN{$file=$ARGV[0]; $pwd=`pwd`;} s/^HOME=.*/$pwd/;
> END{unlink($file . ".bak");}'
>
> Now this is just UGLY!  Is there an easier way (even not in perl) to get
> what I want.
>
> Thanks!
> Tanton
>

Gyro



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to