How to escape password for smb mount I want to mount a SMB share with different user credentials. Therefore I want to use

mount -o nodev,nosuid -t smbfs //user:pass=&lt;word@host/share /mnt/share


However, this command fails:

-bash: word@host/share: No such file or directory


When trying to pass the password via a variable, I get:

$ export PWD="pass=&lt;word"
$ mount -o nodev,nosuid -t smbfs //user:$PWD@host/share /mnt/share
mount_smbfs: URL parsing failed, please correct the URL and try again: Invalid argument


mount on other systems seems to accept username and password as mount options, like:

$ mount -o nodev,nosuid,domain=mydomain,username=user,password="pass=&lt;word" -t smbfs //host/share /mnt/share 


or via a credentials file:

$ cat credentials.txt
username=user
password=pass=&lt;word
domain=mydomain
$ mount -o nodev,nosuid,credentials=./credentials.txt -t smbfs //host/share /mnt/share 


However, both ways are not available with macOS' mount:

mount_smbfs: -o credentials: option not supported
mount_smbfs: -o domain: option not supported
mount_smbfs: -o username: option not supported
mount_smbfs: -o password: option not supported


So the question is: How to provide the password to macOS' mount_smbfs? I'm aware that changing the password would solve the problem, but for reasons this is not an option.
Slightly offtopic, but maybe useful if you want to stick to putting credentials with special chars in a Shell variable.
Regarding your bash commands I will point you to several topics:


PWD is a always present ENV variable showing the current working
directory (Print Working Directory). Omit using that name for a PassWorD variable :-).
There is a significant difference in using double quotes and single
quotes. Double quotes embrace a string, which also can contain expandable variable names and is always subject to escape problems. Single quotes define a fix string and will be treated as such, e.g. no variable expansion will be done.


Example:

# fix string
tatooine-2257:~ mallert$ export P='&lt;word'
tatooine-2257:~ mallert$ echo $P
&lt;word
# no variable expansion
tatooine-2257:~ mallert$ export P='&lt;word $PWD'
tatooine-2257:~ mallert$ echo $P
&lt;word $PWD
tatooine-2257:tmp mallert$ echo $PWD
/tmp



Finally - treat variable names in expansion distinguishable from usual text like referring to ${variablename}. (Bourne Shell style)
Try open 'smb://username:password@server/share' - it creates the volume mount for you. If you omit the password, Finder will ask you for it.