The tag has no usage guidance.

learn more… | top users | synonyms

2
votes
2answers
350 views

Bash command: is it possible to pass an argument before a custom command (function) or it must be only after:

I am wondering if it is possible to pass an argument to a custom command before the command? Let say I have custom command ping and I would like to pass the IP address before command: instead ping 1....
0
votes
2answers
54 views

Script not able to generate files for backup file

I'm new to shell scripting and I trying to write a script that: Prompts for a directory Loops through the directory If it find files it then backs them up using a function in the script Creates a ...
5
votes
1answer
592 views

How to enable `sudo` with custom functions?

Recently I learned you can enable sudo for custom aliases as follows: alias sudo='sudo ' # note: the space is required! The reason this works is the following: If the last character of the ...
3
votes
1answer
255 views

Errtrace and local

I am using the following script: #!/bin/bash -Eu trap 'echo Hi' ERR exit_failure() { echo "Hello, World!" return 1 } sub_failure() { res=$(exit_failure) } sub_failure It results in the ...
0
votes
1answer
203 views

Ugly bash function to send commands and “say” anything in screen over ssh. Is there a better way?

I’m working on a function this works but it is ugly. One thing that could be changed is being able to know the name of the screen. Using screen -dms minecraft java ….jar now starts a screen session ...
3
votes
0answers
36 views

SIGINT is not cleaned up in “${FUNCNAME[@]}”

Take the following script, interrupted by keyboard input ^C as shown: $ function a() { echo "Performing"; sleep 10; echo "Performed"; } $ a Performing ^C $ echo "${FUNCNAME[@]}" a source If we ...
1
vote
0answers
29 views

Save return value from a function in one of its own parameters

Function: Func1() { str1=$2 $1=$str1 } Call function: local var1 Func1 var1 "Helle World" echo $var1 I know this will work but I guess it's not very "pretty": Func1() { str1=$2 eval ...
1
vote
0answers
17 views

Returning an array from a ksh93 function

I would like to return an array from a function in ksh93. At this point, using the following method, the contents of the array are passed as a single element even though, in the fonction, the array ...
1
vote
0answers
115 views

export -f in .bashrc after upgrade to bash 4.3.30 kills builtins?

I recently upgraded my bash (Mac OS X 10.6.8) from 3.2.48(1) to 4.3.30(1) via macports, and while the install seems to have gone smoothly, the two spots in my ~/.bashrc where I had export -f myfunc; ...
0
votes
0answers
81 views

zsh function: maximum nested function level reached

Consider this simple function I am trying to add in my .aliases (dnf is Fedoras newest replacement of Yum): function abc() { dnf search something } It works well on Bash but I get the following ...
0
votes
0answers
16 views

How do I compute the angle of the 2D 3 points ? [[ In kernel space]

I 'm looking at the touch driver 's Kennel. Sometimes a touch is bouncing County singah appear. Collected by recruiting three points 'm trying to calculate the angle between . But there is no such ...
0
votes
0answers
29 views

How do i run multiple scripts within another script in the same directory?

Last part of a project and I've created 3 scripts already that do the following, but I now need to run them within a 4th script as if it was one program. Below are the instructions as well as the code ...
0
votes
0answers
29 views

Lttng tracepoint(provider,tpname, arg)

I want to insert lttng - tracepoint("traceprovider_name"tracepoint_name" "$1"$2") statements with same tracepoint_name and traceprovider_name but with different arguments: for example: 1)How to ...
0
votes
0answers
46 views

Pass a function arguments?

How would you make a function that gets arguments? function arg_example { arg "c" # This is imaginary but it would return 'true' if it found the argument -c. did_find_arg=$? # Get the ...