Skip to main content

All Questions

3 votes
4 answers
1k views

Bash function inside function: How to interpolate certain variables from outer function

I'm trying to create a function that creates a function. I want to "hardcode" an argument in the inner function based on what is passed into the outer function, e.g. outer() { inner() { ...
Andrew Cheong's user avatar
2 votes
0 answers
97 views

zsh: Make getting the value of a variable invoke a function

I like to use a "getter" function for some variable foo, such that using "$foo" is equivalent to "$(foo-getter)". It think this should be possible, as $EPOCHREALTIME ...
HappyFace's user avatar
  • 1,684
0 votes
0 answers
16 views

assign to a number named variable to mimic command line argument [duplicate]

I have a script where I am passing commands to processes with an arguments passed from command line and from environment variables as well. To simplify my use case lets assume my processes are echo ...
jangorecki's user avatar
0 votes
2 answers
2k views

Using shell 'printf' where the format string is in a variable and doesn't have a fixed number of field placeholders?

I am writing a shell function which makes an external API call via cURL (the external API syntax isn't under my control). I've approached it like this (simplified): #!/bin/sh template_get_entry='...
Stilez's user avatar
  • 1,291
1 vote
1 answer
1k views

Declare as local var will break a function and log out "1: number expected"

function projectopen { local di_files=(*.xcworkspace */*.xcworkspace *.xcodeproj */*.xcodeproj) # open first exsit file ls -d -f -1 $di_files 2>/dev/null \ | head -1 \ | xargs ...
Karl's user avatar
  • 235
0 votes
1 answer
987 views

Why does a working standalone nested function/script not work inside a larger script? [duplicate]

The following (nested) function/s function hpf_matrix { # Positional Parameters Matrix_Dimension="${1}" Center_Cell_Value="${2}" # Define the cell value(s) function hpf_cell_value { ...
Nikos Alexandris's user avatar