help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] skip a script based on own filename variable


From: Roman Rakus
Subject: Re: [Help-bash] skip a script based on own filename variable
Date: Sun, 21 Apr 2013 21:45:12 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/17.0 Thunderbird/17.0

If you are using globbing for file names (I assume you are, if you use them sorted by names), you can try to play with GLOBIGNORE variable.

RR
On 04/20/2013 07:56 PM, adrelanos wrote:
Hi!

I have a folder with chroot scripts. (Scripts which are run inside a
chrooted environment.) Those are run with run-parts, which is awesome,
because their execution is sorted by name.

Some names include:
20_root_check
30_sanity_checks
...
70_update_command_not_found
...

For debug builds, I'd like to skip some of the less important chroot
scripts. I thought, if I could make some kind of build configuration,
that'd be nice. Such as

Outside:
export 70_update_command_not_found=0
70_update_command_not_found:
set -x

      
OWN_FILENAME="$(basename $0)"

      
if [ "$OWN_FILENAME" = "0" ];
   true "INFO: Skipping $OWN_FILENAME, because $OWN_FILENAME is set to 0."
fi
This doesn't work, because bash doesn't accept variable names starting
with numbers.

Ok, another idea...

Outside:
export WHONIX_BUILD_CONFIG=("70_update_command_not_found")
70_update_command_not_found:
for setting in "address@hidden"; do
  if [ "$setting" = "$OWN_FILENAME" ]; then
     true "INFO: Skipping $OWN_FILENAME, because $OWN_FILENAME is set
in WHONIX_BUILD_CONFIG."
     exit 0
  fi
done
This doesn't work either, because according to man bash, it does not
(yet) support exporting arrays.

So I told you now, what I'd like to do and what I tried already. I am
looking for some generic code to deactivate chosen scripts by name.
(Setting some SKIP_UPDATE_COMMAND_NOT_FOUND would work, but it's not
generic.) How could I best allow deactivating any chroot script based on
variables set outside and the filename alone?

Cheers,
adrelanos



reply via email to

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