Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

10
  • What shell are you using? Note that you are reading code from the user. As such, it would need to undergo an extra step of evaluation before the actual value (the pathname) is had. Such an evaluation could be done with eval, but if you're using the zsh shell, then there are better (safer) ways of doing that. Commented Feb 22, 2021 at 10:13
  • eval usage on user input is probably no good idea, because it could lead to the user executing commands you have not intended. Commented Feb 22, 2021 at 10:16
  • @Kusalananda thanks, I have updated to describe the shell. Commented Feb 22, 2021 at 10:17
  • 1
    And if the user enters $(reboot) or ${HOME+$(reboot)}, should ls -la $web_application_root reboot? Commented Feb 22, 2021 at 10:19
  • 1
    @nishanthshanmugham ${(e)web_application_root} would expand the variable web_application_root to $HOME/www and then apply a second re-evaluation to the result, expanding any further variable. Commented Nov 29, 2022 at 12:43