{
  "id": 5220093,
  "title": "A double-quoted $HOME sent three of my directories nowhere I could find them",
  "url": "https://urgent.news/2026/09/03/a-double-quoted-home-sent-three-of-my-directories-nowhere-i-could",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-09-03T01:37:24.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/mahirhir/a-double-quoted-home-sent-three-of-my-directories-nowhere-i-could-find-them-5djc"
  },
  "original_language": "en",
  "account": "A PowerShell script inadvertently sent three of the author's directories nowhere, as the double-quoted $HOME variable expanded prematurely. The author was using the WSL (Windows Subsystem for Linux) from a PowerShell script to run commands on the Linux side. The PowerShell command was structured as follows: `wsl -d Ubuntu-24.04 -- bash -c mkdir -p $HOME/build && cd $HOME/build && ...`.\n\nThe issue arose because PowerShell treats backslashes as escape characters, while PowerShell does not. So, when `$HOME` was placed inside a double-quoted PowerShell string, it expanded the variable right away, turning it into a literal backslash followed by the rest of the variable. This resulted in a Windows-style path without any separators, which Bash didn't recognize as a valid absolute path and treated it as a relative path instead.\n\nAs a result, the `mkdir -p` command created directories with mangled names in the current working directory, rather than the intended home directory. These directories were found later, scattered across different working directories, with names reflecting the broken Windows path. The author suspected that the Windows-style backslashes were stripped away during the transit through quoting and re-quoting processes before reaching the WSL command line.\n\nThe solution to the problem was straightforward: use single quotes in PowerShell. By encasing the variable within single quotes (`' $HOME/build '`), PowerShell would no longer interpret the $HOME as a variable, and Bash would resolve it against its own environment when it encountered the command. This change ensured that the directories were created correctly in the intended home directory. The author emphasized that the failure wasn't immediately apparent, as the `mkdir -p` command executed successfully and the script continued running. The only indication of the issue came from the presence of oddly-named directories that were noticed later during a routine directory listing.",
  "summary": "A double-quoted $HOME sent three of my directories nowhere I could find them I was calling into WSL from a PowerShell script, the way I do a dozen times a day: build a command string, hand it to wsl , let bash do the real work on the Linux side. Something like this, simplified down to the part that mattered: wsl -d Ubuntu-24.04 -- bash -c \"mkdir -p \\ $HOME /build && cd \\ $HOME /build && ...\" The…",
  "key_points": [
    "PowerShell script inadvertently sent directories nowhere",
    "Double-quoted $HOME expanded prematurely",
    "Single quotes solution created directories correctly"
  ],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}