Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 6807

Raspberry Pi OS • Re: How to rename root partition on Rpi5

$
0
0


aliases are not normally expanded in scripts. (I.e., only in interactive shells)

Note that OP didn't explicitly mention "scripts", but that is the inference I took from his posts.
I should have read https://www.gnu.org/software/bash/manua ... iases.html

Functions are likely not to need other recursive workarounds . Can functions be made common to every script (source SOMEPATH/commonFunctions.sh or better?)
Note: I have not done any research before posting this; these comments are just "off the cuff".

I think the general answer to what seems to be the gist of your question is: Yes, but you probably don't want to.

I think there are options to make it expand aliases (and probably also functions), but these options are off by default and with good reason. If you are writing a script, you want commands to do expected things and not be "spoofable".
I.e., if someone has a ~/bin/ls that does something other than what /bin/ls does, that could screw up your script. So, in general, you don't want functions and aliases changing the meanings of commands.

Note that this consideration can affect the choice of whether to write something as a (stand alone) script or to write it as a function. If you write it as a function, then aliases do come into play - which can be either a good thing or a bad thing... I run into this from time to time because if you write a function (in an interactive shell, that has aliases) and it uses "grep", it will catch the aliased version of "grep" (see the default .bashrc and/or .bash_aliases) rather than the genuine "grep".

Anyway, enough rambling...

Statistics: Posted by dbrion1 — Wed Jan 17, 2024 3:03 pm



Viewing all articles
Browse latest Browse all 6807

Trending Articles