Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] /usr/bin/echo eats "-E", but amber does not handle the case #619

Open
lens0021 opened this issue Nov 25, 2024 · 5 comments
Open

[BUG] /usr/bin/echo eats "-E", but amber does not handle the case #619

lens0021 opened this issue Nov 25, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@lens0021
Copy link
Contributor

lens0021 commented Nov 25, 2024

Describe the bug

/usr/bin/echo eats the token "-E" because it seems to be [SHORT-OPTION] of echo. So the next things happen:

  1. echo "-E" prints nothing.
  2. let flag = "-E" sets flag as ""

To Reproduce

amber eval -- 'echo "-E"'
amber eval -- 'const flag = "-E"; echo flag'

The both commands print nothing.

Expected behavior
-E should be printed.

Additional context
Because of this, the next flag is set as "-r" or "", so that the replace_regex does not work as expected.

let flag = status == 0 then "-r" else "-E"

@lens0021 lens0021 added the bug Something isn't working label Nov 25, 2024
@github-project-automation github-project-automation bot moved this to 🆕 New in Amber Project Nov 25, 2024
@lens0021

This comment was marked as outdated.

@Mte90
Copy link
Member

Mte90 commented Nov 25, 2024

What is the bash generated?

@lens0021
Copy link
Contributor Author

lens0021 commented Nov 25, 2024

amber echo "-e" is compiled to bash echo "-e" currently. But it should be echo -- "-e".

From man echo: > -e Enable interpretation of backslash escapes. > > Unlike other shells, this echo accepts -- to signal the end of the options.

(Edited: -- is from the fish shell built in echo)

@lens0021
Copy link
Contributor Author

amber let flag = "-E"; echo flag → bash __0_flag="-E"; echo "${__0_flag}" and the output is also empty.

One solution I can think is replacing echo {} with printf "%s\n" {}, but I cannot tell it has no side effects.

@lens0021 lens0021 changed the title [BUG] Cannot set a variable as "-E" [BUG] Cannot print solely "-E" or set a variable as "-E" Nov 25, 2024
@lens0021 lens0021 changed the title [BUG] Cannot print solely "-E" or set a variable as "-E" [BUG] /usr/bin/echo eats "-E", but amber does not handle the case Nov 25, 2024
@Mte90
Copy link
Member

Mte90 commented Nov 26, 2024

@hdwalters what do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants