The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

egbegb (2) [Avatar] Offline
#1
I seem to be frustrated in my attempts to deai with viables and aliases.
HOME is defined one way in $env:home and another in $home. $home
is wrong, but I can't delete it or change it. Apparently, 'home' is hardwired into
PowerShell. Is this a bug? My %HOME% in the enviroment ($HOME in cygwin)
is the correct value and is embedded in the registry properly. "ls" (ell ess) is another whose aliased definition is not to my liking, but

remove-item alias:ls

worked fine.

I also use the Unix diff command a lot. However, alias:diff seems also to
be hardwired.

Attempts to remove fail:
remove-item variable:home - errs saying 'home' is a constant.
remove-item alias:diff - errs saying 'diff' is a constant.

This seems very antisocial to me. Does anyone on this forum know why this is?

Ed Bradford
Kiron (38) [Avatar] Offline
#2
Re: Readonly and the environment
Set-Variable's -force parameter will replace a ReadOnly variable, if the variable has other options you can replace them through the -option parameter:

$varOption = (Get-Variable HOME).options
Set-Variable -name HOME -value "testing" -option $varOption -force

To remove a ReadOnly alias, use Remove-Item with its -force parameter:

Remove-Item alias:diff -force