Skip to content

Keep quotes in answers read by _read and _read_rep - #3076

Merged
ivan-hc merged 1 commit into
ivan-hc:mainfrom
sagarrsharmaa:fix/template-read-quotes
Nov 26, 2026
Merged

ivan-hc merged 1 commit into
ivan-hc:mainfrom
sagarrsharmaa:fix/template-read-quotes

Conversation

@sagarrsharmaa

@sagarrsharmaa sagarrsharmaa commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

_read and _read_rep save the answer with eval "$var_name='$results'", so the answer is parsed again as shell code. Any answer containing a single quote breaks:

  • am -t: a description like It's a tool prints unexpected EOF while looking for matching `'' and the script is thrown away with "OPERATION ABORTED!"
  • a one-line download command such as curl -Ls URL | sed 's/a/b/' | grep -o 'https.*AppImage' | head -1 is written to the script with its quotes stripped
  • an app name like Bob's App leaves Name= empty in the launcher
  • under dash/busybox sh (the POSIX branch of _read_e) the syntax error exits the shell

The template prompts started hitting this in 21a7b3b, when they moved from read -r -ep ... VAR to _read_rep. _read has had the same line since -y support was added, so free-text answers like a custom launch command or a sandbox directory are affected too.

eval "$var_name=\$results" expands only the variable name and assigns the value unchanged, and it's still POSIX sh. Two lines changed, no prompts touched.

How I tested it: in a Debian container with am -t and typed answers containing ', ", $, backslashes and the curl one-liner above, the generated script now contains exactly what was typed. Blank answers, the -y defaults and the category/binary prompts from #3075 behave as before. The helpers also pass under bash, dash and busybox sh, regress/test-am-template-similar.sh passes, and bash -n is clean.

_read and _read_rep save the answer with eval "$var_name='$results'",
so the answer gets parsed again as shell code inside single quotes, and
any answer with a ' in it breaks. In "am -t", a description like
"It's a tool" fails with "unexpected EOF while looking for matching"
and the script is thrown away with OPERATION ABORTED, an app name like
"Bob's App" leaves Name= empty, and a one-line download command loses
its quotes. Under dash or busybox sh the same error exits the shell.

The template prompts started hitting this when 21a7b3b moved them to
_read_rep; _read has had the same line since -y support was added.

eval "$var_name=\$results" only expands the variable name and assigns
the value as it is, and it's still plain POSIX sh.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants