0

refferencing How to get the host user home directory in WSL Bash
(I don't have reputation yet to add a comment)

the great answer from @felipecassiors: wslpath "$(wslvar USERPROFILE)"

I am trying to turn this into an alias command and my UserProfile has a space so it causes issues:
alias winhome='cd $(wslpath "$(wslvar USERPROFILE)")'

When I run 'winhome':
# -bash: cd: too many arguments

I've tried several ways to add quotes or escape the space - to no avail.

1 Answer 1

2

okay. it became obvious once I hit the nail on the head:

alias winhome='cd "$(wslpath "$(wslvar USERPROFILE)")"'

1
  • Yes. Each $() has its own quoting context, so quotes inside don't mix with quotes outside. Double quoting $() is the right thing. Oct 30, 2020 at 15:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .