12
votes
2answers
341 views

Should I use $* or $@?

Which one of $* or $@ is better to use (in array syntax,command line parameters, etc.) to avoid any bugs/problems in code? Or it does not make any difference?
2
votes
4answers
194 views

How to write a very simple wrapper that provides default parameters?

Given a program that requires some parameters, e.g. program -in file.in -out file.out, what would be the simple-most approach to write a bash script that could be called with or without any of these ...
1
vote
1answer
323 views

Passing Command Line Arguments to java From JPackage Script

I installed Rachota -- a time tracking program written in Java -- from the Fedora repo, and yum installed the rachota.jar file to /usr/share/java, but it also created a script at /usr/bin/rachota. ...
4
votes
1answer
302 views

Writing command synopsis in standard man format

I am writing a script and in the usage() function I want to specify the usage. My script uses either option1 or option2 or both. One of them is mandatory. Is there a standard way to write it up?
7
votes
1answer
10k views

How to check if there are no parameters provided to a command?

How do you check if $* is empty? In other words, how to check if there were no arguments provided to a command?
5
votes
3answers
3k views

Print shell arguments in reverse order

I am a bit stuck. My task is to print the arguments to my script in reverse order except the third and fourth. What I have is this code: #!/bin/bash i=$# for arg in "$@" do case $i in ...
11
votes
2answers
1k views

How to safely pass variables to root-enabled scripts?

This question is totally general and not only applicable to my situation, but... I have a small busybox appliance where I want a non-root user to be able to execute a particular script with root ...