Repository navigation
Closed
Labels
Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aUsability(LEGACY) Helps filter issues that might be higher priority because they directly affect usability(LEGACY) Helps filter issues that might be higher priority because they directly affect usability
Milestone
Description
We have 24 conflicting names between PS aliases and /bin, /usr/bin, etc folders
# /bin
cat
cp
echo
kill
ls
mv
ps
pwd
rm
rmdir
sleep
# /usr/bin
cd
clear
cpp
diff
fc
man
ri
sort
tee
type
write
# /usr/sbin
ac
# /sbin
mount
We need to figure out what's out story about it.
I think it make sense to play around with different options to see pros and cons on practice.
Try it (the snippet is outdated, see the new snippet for 0.3.0 bellow)
You can add this snippet to your profile and easily switch from one mode to another
- Remove-PSAliases will remove aliases, so you can use native utilities.
- Set-PSAliases will restore aliases.
$global:__aliases = @(
'cat',
'cp',
'echo',
'kill',
'ls',
'mv',
'ps',
'pwd',
'rm',
'rmdir',
'sleep',
'cd',
'clear',
'cpp',
'diff',
'fc',
'man',
'ri',
'sort',
'tee',
'type',
'write',
'ac',
'mount'
)
function Set-PSAliases
{
$global:__aliases | % {
Write-Host "Adding $_"
Set-Alias $_ $global:__aliases_backup[$_] -Scope Global
}
}
function Remove-PSAliases
{
if (-not $global:__aliases_backup) {
$global:__aliases_backup = @{}
$global:__aliases | % {
$global:__aliases_backup[$_] = (Get-Command $_).ResolvedCommandName
}
}
$global:__aliases | % {
Write-Host "Removing $_"
while (Test-Path alias:$_) {
Remove-Item -Force alias:$_
}
}
}Metadata
Metadata
Assignees
Labels
Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aUsability(LEGACY) Helps filter issues that might be higher priority because they directly affect usability(LEGACY) Helps filter issues that might be higher priority because they directly affect usability
Activity
andyleejordan commentedon Feb 21, 2016
Is this much of an issue? A user of PowerShell, I think, would expect the cmdlets to be preferred because of their object-orientedness, and the native commands can be easily accessed by absolute path or
Get-Command.vors commentedon Feb 21, 2016
Just observed that I did a look-up only in
/bin, but not in other folders from PATH.The original list of 11 indeed looks fine.
I'm worry about
diffandmount.Diff (Compare-Object) behaves very differently from what you would expect (i.e. there is no way to perform a diff in git sense of diff. Lines order is always lost).
I even wrote a normal diff tool as one of the first things for PS https://github.com/vors/PSCompareCollection
Mount is tricky for the same reason. It behaves too differently and PS version is not a true replacement.
andyleejordan commentedon Feb 22, 2016
I agree,
diffandmountare worrisome because the Linux behavior is likely to be preferred by default, same goes forman.zach-folwick commentedon Mar 2, 2016
As a user, I would expect to be forced to either remove or over-ride the default powershell aliases myself, and replace with the linux alternatives, or to use the absolute path of the external command. I don't see how this breaks down with diff and mount.
vors commentedon Mar 2, 2016
When I think thru the first time experience for somebody, who never tried powershell, but know bash
cd,cd,ls, wow the output looks different, I guess I can live with that.ps,kill, yada yada, well this guys did a decent job replicating Unix utilities.diff, wait what? Whatdiffdoes? You kidding.exitand stay away from itIn this thought experiment, the concept of aliases vs full command path even doesn't come to play.
andyleejordan commentedon Mar 23, 2016
From Jeffrey Snover (@jpsnover):
andyleejordan commentedon Apr 2, 2016
For the 0.3.0 release, we will remove all the conflicting aliases.
joeyaiello commentedon Apr 7, 2016
We have a naive agreement that most of these need to be removed at build-time on just Linux, with the exception of a few that still need to be defined (e.g.
cd).That being said, there's some more thinking we have to do. One option is to create a formatter that makes the output of something like Get-Process look like the string output of '/bin/ps', and then enable it being piped to awk/sed. We have to think about it more.
jpsnover commentedon Apr 7, 2016
The mindset for this is that it will be used as an interactive shell by Linux users.
As such we should minimize surprises.
The last time I looked ps (or ls) had like 80 switches so there is no way we are going to emulate that.
Sent from my tablet
andyleejordan commentedon Apr 8, 2016
These are the native command (not Bash built-in) collisions on my Ubuntu 14.04 box.
I'll compile these out of
InitialSessionState.cs. The one thing that I don't like about this approach is that it leaves users without an easy way to put them all back at once (a PowerShell experience).But, in my opinion, all of the built-in aliases would be much better off defined in a module outside of the
System.Management.Automationlibrary to begin with. Aliases really shouldn't be built into an engine; I don't know of any other shell that does this. Bash has default aliases... defined in/etc/bashrcor your default~/.bash_aliasesetc., which lets users and distributions easily modify them.I also had
cliwhich was installed by Mono, andriwhich was installed by rbenv. We could remove these, but there will always be some level of collision among tool names.andyleejordan commentedon Apr 8, 2016
I had these on my OS X box:
I also had
gmwhich is GraphicsMagick,comparewhich is from ImageMagick, andrp, which is a "Tool to find ROP sequences in PE/Elf/Mach-O x86/x64 binaries" and I don't know why I had it installed.andyleejordan commentedon Apr 8, 2016
We do not currently have a compile time constant for OS X as it shares
LINUXsince (so far) every compile time difference has been the same. These changes do not necessarily have to be compile-time; just the current way it's written needs to be refactored to be make these runtime changes.The only differences between the two are that OS X additionally has the
accommand, and (strangely) has native commands for what are only Bash built-ins on Linux:cd,fc, andtype.andyleejordan commentedon Apr 8, 2016
This brings up an interesting point: Bash itself stomps on quite a few native commands with its own built-ins (which are not aliases, but similar). So perhaps my earlier comment on moving them all out was on an erroneous understanding.
Bash built-ins stomp on these on Linux:
And these on OS X:
I am of the opinion to mirror Bash and let PowerShell stomp on these as well, as that would be what Linux users (possibly unknowingly) expect.
vors commentedon Apr 8, 2016
I'm surprised
killis in the list of bash stomped commands. What's the reason for that?On the other hand, why
cdis not in Linux, but it is in OS X?andyleejordan commentedon Apr 8, 2016
My guess is that
killis stomped so thatkillin Bash can deal with Bash jobs properly. I am unsure of the history leading to why BSD but not Linux has a native command forcd.JamesWTruher commentedon Apr 8, 2016
removing the alias for cd isn't going to work very well - it's a shell built-in (even if it does exist in the filesystem)
andyleejordan commentedon Apr 8, 2016
Yes, we should keep the aliases that Bash already had as built-ins, including those that have native executables.
Remove conflicting aliases for Linux and OS X
vors commentedon Apr 12, 2016
Here is a snippet to resurrect aliases in 0.3.0
vors commentedon Apr 12, 2016
TIL,
whichis a built-in command in zsh, but not in bash.It leads to a weird flow:
But really
timeis a built-in keyword.And even worse, it has a different parameters from an util one.
Is the same as
And note, there is no
-l.http://stackoverflow.com/a/19237170/1355726
Remove conflicting aliases for Linux and OS X