Trying to test something and not quite nailing it either way I've tried, so not sure if I'm being silly or not.
Essentially I wantneed to parse a string to ipa-getcertgetcert's post-save argument which should include the date, butyear of the datecertificate renewal. This means the script will run once to request the certificate and then the current year can be some future dateused (simple). But then when ipa-getcert renews a certificate it will run a command with arguments post-save, and it's at this time that depends on an external systemthe year of the renewal must be used. So I'd likeThe whole string to do thisget a certificate issued including the post-save option [-C] is:
RENEW_CMD="$INST_CERTsudo ipa-getcert request -N $CERT_CN -K HTTP/$CERT_CN -k /etc/ssl/private/${CERT_CN}.key -f /etc/ssl/certs/${CERT_CN}.crt \
-D $CERT_CN -C "$INST_CERT -n ${CERT_NAME}_"'$(date +"%Y")'" $INST_OPTS $PAN_MGMT"
Attempting to test this I know the single quotes ensure that the current date isn't parsed as text intotried the variablefollowing, but I want to ensure that it is expanded later on. So I did a simple test and the date is never expanded... Is there a better way to test this, apart from using ipa-getcert to test?
$ txt="The year is: "
$ echo $txt$(date +"%Y")
The year is: 2023
$ echo $txt'$(date +"%Y")'
The year is: $(date +"%Y")
$ echo $(echo $txt'$(date +"%Y")')
The year is: $(date +"%Y")
But echoing the string does, so the single quotes seem to remain even when not printed on screen.
$ echo The year is: $(date +"%Y")
The year is: 2023
Undoubtedly I'm missing something trivial here.
[EDIT:] But then the following works fine, so maybe I'm just paranoid?
$ mkdir $(date +"%Y")
$ test2="ll "'$(date +"%Y")'
$ echo $test2
ll $(date +"%Y")
$ eval $test2
total 8
drwxrwxr-x 2 user group 4096 Apr 24 20:01 ./
drwxr-xr-x 13 user group 4096 Apr 24 20:01 ../