Executing a command named in a variable

Ray Parrish crp at cmc.net
Tue Dec 1 13:46:07 UTC 2009


Avi Greenbury wrote:
> Ray Parrish wrote:
>
>   
>> Hello,
>>
>> I'm thinking of a way to set a default external editor in a bash
>> program I am writing, and need to know if it is possible to execute a
>> command named in a variable that gets set by retrieving the command
>> line for the external editor's command line from a configuration file.
>>
>> Would the following work?
>>
>> # set variable to command line
>> ExecuteEditor="/usr/bin/gedit filename.ext"
>> # execute external command.
>> $ExecuteEditor &
>>     
>
> Yes, assuming you mean bash. 
>
> Did you try it? It's not something that's particularly dangerous to try.
>
> It's worth checking for the existence of the $EDITOR environment
> variable, first, as this is where the user would be expected to have
> declared their preference for vim^H^H^H their favourite text editor.
>
>
>
> --
> Avi Greenbury
> http://aviswebsite.co.uk ;)
> http://aviswebsite.co.uk/asking-questions
>   
Hello,

No, I didn't try it, but a couple of others here on the list say they 
have, and I'll believe them. However I like your idea of checking for 
the environment variable. Thank you for the valuable tip. 8-)

Later, Ray Parrish

-- 
The Future of Technology.
http://www.rayslinks.com/The%20Future%20of%20Technology.html
Ray's Links, a variety of links to usefull things, and articles by Ray.
http://www.rayslinks.com
Writings of "The" Schizophrenic, what it's like to be a schizo, and other
things, including my poetry.
http://www.writingsoftheschizophrenic.com






More information about the ubuntu-users mailing list