arguments

Bash parameter substitution with multi line error message

Bash parameter substitution with multi line error message I’m using parameter substitution with an error message, such as ${var1:?’some message’}. I’ve incorporated a multi-line error message. Presently, it only functions properly when enclosed within single quotes, with line breaks inserted using the Enter key. Is there a clever way to allow acceptance of multiple lines, …

Total answers: 1

Hide single argument from bash history

Hide single argument from bash history Is there a way to hide a single argument passed into the terminal, but still pass the argument to the command? This question addresses the problem of passing a plain-text password through the shell. But, even if not a password, there is a use for selective arguments to be …

Total answers: 2

script arguments in bash

script arguments in bash I am working on a a script that need to take two script arguments and use them as variables in the script. I couldn’t get this working and unable to find out what I am doing wrong. I see the issue is the second argument, as I see in some of …

Total answers: 1

How can I pass $@ to exec.args of Maven?

How can I pass $@ to exec.args of Maven? things I tried in my script run.sh: mvn exec:java -Dexec.mainClass=my.App -Dexec.args="$@" mvn exec:java -Dexec.mainClass=my.App -Dexec.args=$@ when I call the script like: ./run.sh arg1 arg2 arg3 the arguments are not passed to Java application. instead Maven tries to interpret them as if they were maven options. EDIT: …

Total answers: 1

Looking for a more permissive alternative to GNU getopt for wrapper script

Looking for a more permissive alternative to GNU getopt for wrapper script I often find myself writing shell functions or shell scripts that are meant to be wrappers around other commands. It is also frequent that I want such a wrapper to support a few flags/options. The idea is that the wrapper should cull from …

Total answers: 1

function that allows different outputs dependent on argument values

function that allows different outputs dependent on argument values With the following function I want to be able to call it with nico-usage or with a numeric value to print a different string. Con this be cleaned up or made easier. nico-usage () { local docstrg_lang=" {-V, –version}, {-u, –usage}, {-h, –help} -s SCAL, –scale …

Total answers: 1

gnome-terminal how to send commands

gnome-terminal how to send commands For an application, I need to open a new terminal window and later execute some commands in that. I tried the command gnome-terminal And it works properly, it open a new terminal, but when i want to send commands i cannot, it says that failed parsing arguments, so I’m not …

Total answers: 2

Parsing multiple arguments into a bash script

Parsing multiple arguments into a bash script I’ve tried a few solutions posted here, but to no avail. I’m hoping it’s something silly and obvious that I’ve missed, that you can spot easily, and I can facepalm myself. I have a bash script containing multiple commands for data analysis. If I were to run this …

Total answers: 3

Complete a positional argument only once

Complete a positional argument only once I’m trying to write a completion for a command (call it gs) that takes an SSH hostname as its first argument, and an arbitrary string as the second argument. I’ve stolen this from the default SSH completion: # Load completions shared by various ssh tools like ssh, scp and …

Total answers: 1

How to mix plain arguments with flagged arguments in bash scripting?

How to mix plain arguments with flagged arguments in bash scripting? for instance, gcc accepts the input file without any flag and the output file with the -o flag in: gcc input.c -o output.out or gcc -o output.out input.c I am creating a random password generator bash script, the user should be able to specify …

Total answers: 1

How can I apply enscript to upwards of 60k files?

How can I apply enscript to upwards of 60k files? I want to apply Gnu enscript on a large collection of files (every file tracked by git in the current Linux kernel). I have just for the hell of it. However, I’ve tried various things to pass those files as arguments such as a python …

Total answers: 1

Systemd service prefix on ExecStart=@/path/to/executable doesn't change the `argv[0]`

Systemd service prefix on ExecStart=@/path/to/executable doesn't change the `argv[0]` According to the manual man systemd.service using the prefix @ says this: If the executable path is prefixed with "@", the second specified token will be passed as "argv[0]" to the executed process (instead of the actual filename), followed by the further arguments specified. But when …

Total answers: 1

GNU Parallel with named arguments

GNU Parallel with named arguments I have the following command in my Makefile parallel –eta –bar –joblog mnist/embedder.joblog pipenv run python3 -m mnist.train_embedder –embedder_name {1} –embedder_dim {2} –embedder_lr {3} –embedder_epochs {4} :::: grid/embedder_name :::: grid/embedder_dim :::: grid/embedder_lr :::: grid/embedder_epochs Each file contains something like $ cat grid/embedder_name ae cnn $ cat grid/embedder_dim 24 32 48 …

Total answers: 2

Expanding an argument within single quotes

Expanding an argument within single quotes I’m trying to create a function that executes the following composer config repositories.foo ‘{"type": "path", "url": "/b/foo-bundle"}’ I’m starting with lb() { composer config repositories.$1 ‘{"type": "path", "url": "/b/$1-bundle" }’ ; } lb foo But because the argument (a json string) is inside single quotes, it’s generate $1-bundle instead …

Total answers: 2

Call a command from a shell script, passing most arguments, allowing arguments with blanks

Call a command from a shell script, passing most arguments, allowing arguments with blanks I am have a wrapper run_sas.sh around a command sas that runs SAS code in batch. A typical call looks like this ./run_sas.sh -sysin /my_code/my_program.sas -log /my_log_folder/my_program.log run_sas.sh passes all arguments to sas with ./sas $*. sas then runs /my_code/my_program.sas and …

Total answers: 1

Help understanding Bash command-line argument parsing code

Help understanding Bash command-line argument parsing code I want to take two arguments and a third optional one for a script I am developing. I am new working with bash so I have been copying and trying to understand the following code that does what I want (I guess) while [[ $# -gt 0 ]]; …

Total answers: 1

Bash getopts, mandatory arguments

Bash getopts, mandatory arguments I am working with a pretty simple bash script, but I am facing a problem which I can’t resolve: I have myscript.sh with three parameters, -u, -h, and -p. Both -u and -h are mandatory, needed for the script to run. What I would like to do is, if myscript.sh -u …

Total answers: 1