bug-bash
[Top][All Lists]
Advanced

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

Passing command line to scripts and programs


From: Grant Jacobs
Subject: Passing command line to scripts and programs
Date: Mon, 09 Jan 2006 23:58:43 +1300

Item: No environment variable or other easy means is currently available to pass the complete command line to daughter scripts and programs.

Maybe this is a feature request rather than a bug per se, but I'd appreciate those who know better than me bearing with me (I'm happy to hear suggestions where else I might send this).

I am trying (badly!) to find a means that any program or script can obtain the command line that invoked it as a string. I want to avoid hacks that rely on the user remembering anything like pre-pending the command line by setting an environment variable (ugly, untrustworthy). This is *not* the program/script name and its arguments, but the complete command line, including any pipes, redirects, etc. For example, I want do_stuff to be able to get the complete command line that evoked it:

  echo -n "Saving.." ; more some_stuff | \
    do_stuff -D first_*.lst second_*.lst > save_here &

and through this record that the output went to "save_here" and that the original input of save_here was first_*.lst and second_*.lst, for example.

It seems to me that a lack of an easy way of doing this leaves something rather useful missing. (That, or I'm badly missing something! -- in which case if anyone can suggest an existing way of doing this, I'd be most grateful. If you can reply directly that'd be a help as I've yet to locate the mailing list reigstration instructions, etc.!).

A couple of environment variables holding the current unprocessed and shell-processed command lines that are set by the shell for each new command line before its evoked would be ideal and surely not especially hard to implement (?).

Another generic solution might be an equivalent to PROMPT_COMMAND that is evoked before each line, i.e. NEWLINE_COMMAND, although this raises a few questions. The user could then place something like:

  NEWLINE_COMMAND="THISCMD=`history 1`"
  export THISCMD

into their .bash_profile to have THISCMD set up before each line is executed. This could be extended to cover a variety of signal events within the bash shell.


Grant


[gjacobs:gjacobs] bash --version
GNU bash, version 2.05b.0(1)-release (powerpc-apple-darwin7.0)
Copyright (C) 2002 Free Software Foundation, Inc.

(No bugbash on OSX bash, at least by default; same version of bash on darwin8.0, too.)
--
-------------------------------------------------------------------
Grant Jacobs Ph.D.                                     BioinfoTools
ph. +64 3 478 0095  (office, after 10am)               PO Box 6129,
or  +64 27 601 5917 (mobile)                               Dunedin,
gjacobs@bioinfotools.com                               NEW ZEALAND.
   Bioinformatics tools: deriving knowledge from biological data
Bioinformatics tools - software development - consulting - training
 15 years experience in bioinformatics ready to solve your problem
Check out the website for more details: http://www.bioinfotools.com

The information contained in this mail message is  confidential and
may be legally privileged.  Readers of this message who are not the
intended recipient are hereby notified that any use, dissemination,
distribution or reproduction of this message is prohibited.  If you
have received this message in error please notify the sender immed-
iately and destroy the original message.  This applies also to  any
attached documents.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]