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: John Kearney
Subject: Re: [Help-bash] skip a script based on own filename variable
Date: Sun, 21 Apr 2013 12:27:52 +0200
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130328 Thunderbird/17.0.5

Am 20.04.2013 19:56, schrieb adrelanos:
> 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
>
you could do

export WHONIX_BUILD_CONFIG="70_update_command_not_found" # split entries
with : like path

70_update_command_not_found:

> IFS=: for setting in "${WHONIX_BUILD_CONFIG}"; do
>   if [ "$setting" = "$OWN_FILENAME" ]; then
>      true "INFO: Skipping $OWN_FILENAME, because $OWN_FILENAME is set in 
> WHONIX_BUILD_CONFIG."
>      exit 0
>   fi

> done


or something like

> export NL_70_update_command_not_found=0

70_update_command_not_found:

> set -x
> OWN_FILENAME=$(basename $0 .sh)"
> if [ "${!NL_${OWN_FILENAME}}" = "0" ];
>    true "INFO: Skipping $OWN_FILENAME, because 'NL_$OWN_FILENAME' is set to 
> 0."
> fi





reply via email to

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