title: Building simple shell script which executes program passed as argument
body: <p>I am building a program which helps in memory debugging of C programs. I call</p>
  
  <pre><code>execlp("gnome-terminal","gnome-terminal","-e",command,(char*)0);
  </code></pre>
  
  <p>to open a new terminal window where the program to be debugged runs. I do this to not have my debugging info intermixed with the users program output. Because I need to set up an environmental variable before running the users program, command var is actually the name of the shell script where I pass the users program as the first arg.</p>
  
  <p>Here is my script:</p>
  
  <pre><code>#!/bin/bash
  
  export LD_PRELOAD="./mylib.so"
  $1
  </code></pre>
  
  <p>This works fine for programs with no arguments but what happens if the user also supplies args with his program? </p>
  
  <p>For example I wish to call my script like that : </p>
  
  <pre><code>myScript.sh usersProgram arg1 arg2 etc
  </code></pre>
  
  <p>How can I correctly run the users program inside the script and pass all the arguments to it?</p>
  
  <p>Thank you</p>