Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > PowerShell

i don't think you should be allowed to do this

Closed Thread
 
Thread Tools Display Modes
Old 10-07-2006   #1 (permalink)
klumsy@xtra.co.nz
Guest


 

i don't think you should be allowed to do this

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

Old 10-07-2006   #2 (permalink)
Adam Milazzo
Guest


 

Re: i don't think you should be allowed to do this

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.
Old 10-09-2006   #3 (permalink)
James Truher
Guest


 

Re: i don't think you should be allowed to do this

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
>



Old 10-10-2006   #4 (permalink)
Roman Kuzmin
Guest


 

Re: i don't think you should be allowed to do this

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


Old 10-11-2006   #5 (permalink)
dreeschkind
Guest


 

Re: i don't think you should be allowed to do this

"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
Old 10-11-2006   #6 (permalink)
Roman Kuzmin
Guest


 

Re: i don't think you should be allowed to do this

"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


Closed Thread

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Access to directories not allowed George Vista performance & maintenance 5 09-23-2007 07:55 PM
Uninstall not allowed in Vista sbmmm Vista installation & setup 8 09-20-2007 10:38 AM
Folder listing not allowed Jens Müller Vista security 1 03-25-2007 05:47 PM
Backup to CD-RW not allowed in Vista RC1? alexander750 Vista performance & maintenance 9 11-07-2006 06:34 PM
Upgrade not allowed from Pre-RC1 to RC2 =?Utf-8?B?Um9uIEhvbGRlcg==?= Vista installation & setup 3 10-08-2006 12:44 PM








Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50