Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

in bash script, see and use the exact entire command line

Is there any way to access the exact command line as typed?

(After variable expansion is OK)

It's the only way I can think of to achieve the following:

myscript.sh file1 file2 file3 -m"A multi word comment" [other parameters/options]

-- and inside the script we effectively call --

svn commit file1 file2 file3 -m"A multi word comment" [other parameters/options]

-- without having to duplicate all the parsing that svn does itself, just to make sense of the command line

(The problem I have is that in the example, $4 is going to be "-mA multi word comment" which is going to be a mess to sort out. I'd rather be able to shoot the whole command-line, quotes and all, straight to svn just exactly how svn will want to see it.)

If anyone knows a better way to write an svn "wrapper", I'd also like to hear it.

like image 743
user1070300 Avatar asked Nov 22 '12 22:11

user1070300


People also ask

How do you echo a command in shell script?

echo command in linux is used to display line of text/string that are passed as an argument . This is a built in command that is mostly used in shell scripts and batch files to output status text to the screen or a file. In above example, text after \c is not printed and omitted trailing new line.

Which is the right syntax to print all the arguments passed to the script?

$* = All the arguments on the command line.


2 Answers

Have you tried in your script:

svn commit "$@"

Explanation:

  • $@ is a special variable that containing all the arguments to the shell, starting at $1.
like image 55
sampson-chen Avatar answered Nov 14 '22 23:11

sampson-chen


Inside effectively call you can:

svn commit "$@"

As for seeing exactly how it is typed — no. You can't tell a b from a b (note one and two spaces between parameters — argh, I think even SO hides the second space ;)). But you don't need to.

like image 37
Michael Krelin - hacker Avatar answered Nov 15 '22 00:11

Michael Krelin - hacker