[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Local variables for nested function calls

From: eduardo-chibas
Subject: Local variables for nested function calls
Date: Wed, 28 Jul 2021 16:53:01 +0200

I have a function `pregion` that is called from another function `plist`.
If `plist` sets the variable `fdir` using `local fdir=${dpath:-$PWD}`
but in `pregion` the variable `fdir` is used without being defined as
local, it then considers `fdir` to be assigned to the value set by the
parent function.

Everything gets very complicated.  I want to ask how to properly handle
things so that they do not come to bite you later on.

Furthermore, is it still acceptable to use `${parameter:-word}` and
`${parameter:=word}` these days ?  Rather than simply using
`[[ $fdir ]] || fdir=this` or `[[ -v fdir ]] || fdir=that`.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]