chef / chef/mixlib-shellout

Preventing environment variable expansion in windows displays unexpected output

Open
#131 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Platform: Windows Type: Bug
Dominant language
Ruby
Stars
133
Forks
73
Avg merge
8h 20m
Merged PRs (30d)
2

Description

I tried to track down the root cause of this but was unable to in the time I had available.

In cmd.exe, running this echo %^COMPUTERNAME% outputs %COMPUTERNAME%

In mixlib/shellout, running

blah = Mixlib::ShellOut.new("echo %^COMPUTERNAME%")
blah.run_command.stdout

outputs %^COMPUTERNAME%. I would expect the carat to be removed like it is in cmd.exe.

The end result of this behavior is that I can't run commands that expected unexpanded environment variables as arguments.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The behavior is exposed through Mixlib::ShellOut in mixlib/shellout; start by tracing how Windows commands are executed and how stdout is collected. Compare echo %^COMPUTERNAME% with cmd.exe, then verify that the caret is removed while the environment variable remains unexpanded.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
cli, operating-systems
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.