All Questions
6
questions
5
votes
1
answer
3k
views
How to distinguish between a positional parameter and an option?
Both a positional parameter ($1, $2, and so forth) and an option (and/or argument) are written directly after a command, so what is the definition or phrasing to explain how to distinct them?
In ...
0
votes
1
answer
337
views
Create custom parameters (options) for already existing commands?
Recently I 've been wanting to create a custom parameter for pacman.
To elaborate, I have tweaked pacman.conf so that specific packages (linux, linux-firmware, and a couple more) are ignored when I ...
1
vote
1
answer
2k
views
Bash get input while flag present?
I'm writing a bash script that has optional flags but also an input.
I can't get the input as $1 because when flags are present the input is shifted.
So for example if I run script.sh test then $1 ...
3
votes
2
answers
1k
views
Can a bash array be used in place of eval set -- "$params"?
I'm taking a look at the optparse library for bash option parsing, specifically this bit in the generated code:
params=""
while [ $# -ne 0 ]; do
param="$1"
shift
case "$param" in
--my-...
7
votes
2
answers
7k
views
Getopts option processing, Is it possible to add a non hyphenated [FILE]?
I'm using getopts for all of my scripts that require advanced option parsing, and It's worked great with dash. I'm familiar with the standard basic getopts usage, consisting of [-x] and [-x OPTION]. ...
5
votes
4
answers
941
views
How can I create a empty file whose name begins with a dash? [duplicate]
How can we create a empty file with the unix name -stuff.
It means the name start with -. I tried with touch -stuff but it didn't work.