Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

quoting question



Hi everyone,

Zsh quoting at times makes me wonder. Do quoting? Don't do quoting?
The following case has me scratching my head.  Can someone explain what is
going on?

datetimetest ()
{
  local     DT
  DT="${(%):-%D{%Y-%m-%d %H:%M:%S %Z}}"
  print $DT
  DT=${(%):-%D{%Y-%m-%d %H:%M:%S %Z}}
  print $DT
  print -- "${(%):-%D{%Y-%m-%d %H:%M:%S %Z}}"
  print -- ${(%):-%D{%Y-%m-%d %H:%M:%S %Z}}
  print -- "Date and Time:  ${(%):-%D{%Y-%m-%d %H:%M:%S %Z}} Test"
}

Output:

2023-09-12 13:21:40 CDT}    <--  why "}" when quoted
2023-09-12 13:21:40 CDT
2023-09-12 13:21:40 CDT}    <--  why "}" when quoted
2023-09-12 13:21:40 CDT
Date and Time:  2023-09-12 13:21:40 CDT} Test    <--  why "}" when quoted

ZSH_PATCHLEVEL:  zsh-5.9-208-gf80ad32

Also included test function in an attachment.

Regards,

Jim Murphy
datetimetest ()
{
  local     DT
  DT="${(%):-%D{%Y-%m-%d %H:%M:%S %Z}}"
  print $DT
  DT=${(%):-%D{%Y-%m-%d %H:%M:%S %Z}}
  print $DT
  print -- "${(%):-%D{%Y-%m-%d %H:%M:%S %Z}}"
  print -- ${(%):-%D{%Y-%m-%d %H:%M:%S %Z}}
  print -- "Date and Time:  ${(%):-%D{%Y-%m-%d %H:%M:%S %Z}} Test"
}


Messages sorted by: Reverse Date, Date, Thread, Author