i don't think you should be allowed to do this:
set-Alias "," get-Process
dir alias:
&','
i think that you shouldn't be able to set as aliases things like build
in operators and keywords.
Karl
i don't think you should be allowed to do this:
set-Alias "," get-Process
dir alias:
&','
i think that you shouldn't be able to set as aliases things like build
in operators and keywords.
Karl
klumsy@xtra.co.nz wrote:
> i don't think you should be allowed to do this:
>
> set-Alias "," get-Process
> dir alias:
> &','
>
> i think that you shouldn't be able to set as aliases things like build
> in operators and keywords.
>
> Karl
Why not? :-)
It might be useful for debugging scripts, if nothing else.
my philosophy on these sorts of things have been pretty much a "you know
what you're doing" approach - If you want to:
buy a gun
buy the bullets
load the gun
point it at your foot
pull the trigger
I figure, you did what you wanted to do, why should I tell you that you're
wrong? I suppose I could warn you that you're going to shoot yourself in
the foot, but, then again, if that's what you really want to do, you might
just as easily get mad at me for warning you.
Also, if I disallow the aliasing as you request, I wouldn't be able to
create the alias foreach (foreach-object) - since foreach is a keyword as
well as an alias.
--
--
James Truher [MSFT]
Windows PowerShell Development
Microsoft Corporation
This posting is provided "AS IS" with no warranties, and confers no rights.
<klumsy@xtra.co.nz> wrote in message
news:1160276019.644246.99050@k70g2000cwa.googlegroups.com...
>i don't think you should be allowed to do this:
>
> set-Alias "," get-Process
> dir alias:
> &','
>
>
> i think that you shouldn't be able to set as aliases things like build
> in operators and keywords.
>
> Karl
>
James,
Nice explanation.
I also think that there is nothing wrong that PowerShell allows funny named
aliases (not only aliases, variables and functions too). For example for
some reason I have a function '=' (I also could have an alias '=' instead)
and I am quite happy to be allowed to do this.
--
Thanks,
Roman
"Roman Kuzmin" wrote:
> I also think that there is nothing wrong that PowerShell allows funny named
> aliases (not only aliases, variables and functions too).
In general I prefer to allow only characters that contain: a-z / A-Z / 0-9 / _
In many programming languages only these characters are allowed or at least
recommended to use for naming variables, functions and classes etc.
Hence, I was suprised that PowerShell allows so many special characters,
like for example the colon ":" in the wacky psdrive helper functions "a:" -
"z:".
I don't think this is a good idea.
Sometimes it might be a good idea to protect people from doing stupid things
(like using "funny" names for variables and aliases or even shooting in your
foot).
As with the foot, this will only cause pain when somebody (you?) has to read
your obfuscated code.
Btw.: What if we get the ternary operator ? : someday?
What will happen with the ? alias for where-object cmdlet?
This might cause some confusion...
> For example for
> some reason I have a function '=' (I also could have an alias '=' instead)
> and I am quite happy to be allowed to do this.
May I ask what this function does?
--
greetings
dreeschkind
"dreeschkind" wrote
> May I ask what this function does?
All right, though it's a bit personal and not essential. This is a
function which I never use in normal code; that is why I use a funny name,
normal names are still free for normal functions. This function (omitting
details) is something like that:
param($0, $1, $2, $3, $4, $5, $6, $7, $8, $9)
...
Invoke-Expression $cmd
where $cmd is taken, say, from the registry by name $0. Other parameters $1,
.... $9 may be used in $cmd command template.
E.g.
Name: gv
Value: Get-Variable -Scope global | sort Name | Format-Table *
Example: =gv
Name: wiki
Value:
[System.Diagnostics.Process]::Start("http://en.wikipedia.org/wiki/$1")
Example: =wiki PowerShell
In other words these are parameterised aliases with templates stored
somewhere (in the registry).
It is just a personal toy. I would not recommend it to somebody else, but if
it is fun for me, why not? And in this case a funny name for funny thing
looks quite natural.
--
Thanks,
Roman
| Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Re: SNMP not allowed | Alan Morris [MSFT] | Vista print fax & scan | 0 | 29 Nov 2009 |
| some emails being bounced when others allowed | fend | Live Mail | 10 | 25 Apr 2008 |
| how to fix error 'NUL characters are not allowed' | Ginger | Vista mail | 16 | 18 Nov 2007 |
| Uninstall not allowed in Vista | sbmmm | Vista installation & setup | 8 | 20 Sep 2007 |
| Upgrade not allowed from Pre-RC1 to RC2 | =?Utf-8?B?Um9uIEhvbGRlcg==?= | Vista installation & setup | 3 | 08 Oct 2006 |