Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • otherwise the shell might hose you.
    • Might? With that broken join I’d say it’s a certainty that at some point the shell will hose him. Plus it’s less and simpler code:

      BEGIN {
          if(! $ENV{LD_LIBRARY_PATH} ) {
              $ENV{LD_LIBRARY_PATH} = join(':', @some_paths_I_need);
              system($^X, $0, @ARGV);

      Also: why system(...); exit and not exec?

      • Just out of curiousity, why is that join broken?

        Also, I didn't use exec because I didn't know how the security restrictions around LD_LIBRARY_PATH were enforced. Using exec means the process continues to have the same pid, system gives me an entirely new process. I wasn't sure if having the same pid would allow me to do what I wanted to do.

        But thanks for the clarification. It works correctly (at least on the Linux machine I tried it on).
        • why is that join broken?

          Because you’re not shell-quoting anything. If there happens to be any space in there, the new copy of the script will have different @ARGV contents. That’s before we even get to other shell meta-characters.

    • You're right about using the list. I was actually debugging it to make sure the command was what I wanted it to be so I was combining it into a string so I could print it to the screen before executing. I just forgot to change it after the fact.