prushik--- via plug on 5 Nov 2019 14:07:30 -0800


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] Weird shell script bug



On November 5, 2019 3:30:25 PM EST, Walt Mankowski via plug <plug@lists.phillylinux.org> wrote:
>Update -- clearly something's weird with how the parameters are being
>parsed. I ended up giving up trying to do it as a shell script and
>rewrote it in Perl:
>
>#!/usr/bin/env perl
>my @args = split / /, @ARGV[1];
>my $cmd = $args[0];
>exec $cmd @args;
>
>On Tue, Nov 05, 2019 at 02:23:24PM -0500, Walt Mankowski via plug
>wrote:
>> Hi everyone,
>> 
>> I've got a weird shell script error that I hope someone can help me
>> figure out. I can go into more detail about why I'm trying to do
>this,
>> but afaict this is xcthe basic problem:
>> 
>> I've got a shell script that's setting LD_LIBRARY_PATH and then
>> running
>> 
>>   exec /bin/sh $*
>> 
>> $* is set to "-c ../build/foo.exe bar baz".
>> 
>> When foo.exe runs it thinks argv==1 and it doesn't see any of the
>> other parameters, and so it aborts.
>> 
>> What am I doing wrong?
>> 

quotes. all you need is to put $* in quotes.
___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug