![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Stderror redirect bug? I think I might have found a bug. The following command (3rd line) properly redirects the error stream to the file: copy-item *.ps1 c:\temp gci c:\temp\*.ps1 | %{$_.IsReadOnly = $true} copy-item *.ps1 c:\temp 2>&1 > foo.txt However if I now add -force, the error stream is no longer redirected to the file: copy-item *.ps1 c:\temp -force 2>&1 > foo.txt That's got to be a bug right? Never mind the fact that -force doesn't "force" the overwrite of a read-only file - grrr. BTW if you think that -force should allow overwrites of readonly files (like it does with UNIX cp -f), then vote on this issue at: https://connect.microsoft.com/feedba...3448&SiteID=99 -- Keith |
My System Specs![]() |
| | #2 (permalink) |
| | RE: Stderror redirect bug? Keith, I played around a little bit with your example and found some more surprising behavior. What about this: C:>'abc' > foo.dat C:>type foo.dat abc C:>'xyz' > foo.new C:>type foo.new xyz C:>(gi foo.dat).isreadonly=$true C:>(gi foo.dat).isreadonly True C:>copy foo.new foo.dat -force Copy-Item : The file 'C:\Documents and Settings\schneger\Local Settings\Temp\foo.dat' already exists. At line:1 char:5 + copy <<<< foo.new foo.dat -force C:>copy -force foo.new foo.dat C:>type foo.dat xyz C:> -force is very well able to overwrite r/o files - depending on the placement in the copy commandline. I agree, this looks like a serious bug in commandline parsing. Gerd "Keith Hill [MVP]" wrote: > I think I might have found a bug. The following command (3rd line) properly > redirects the error stream to the file: > > copy-item *.ps1 c:\temp > gci c:\temp\*.ps1 | %{$_.IsReadOnly = $true} > copy-item *.ps1 c:\temp 2>&1 > foo.txt > > However if I now add -force, the error stream is no longer redirected to the > file: > > copy-item *.ps1 c:\temp -force 2>&1 > foo.txt > > That's got to be a bug right? Never mind the fact that -force doesn't > "force" the overwrite of a read-only file - grrr. BTW if you think > that -force should allow overwrites of readonly files (like it does with > UNIX cp -f), then vote on this issue at: > > https://connect.microsoft.com/feedba...3448&SiteID=99 > > -- > Keith > > > |
My System Specs![]() |
| | #3 (permalink) |
| | RE: Stderror redirect bug? If you read the link the Keith gave it states the the first time you run the copy with the force switch and clears the readonly flag but doesn't actually do the copy. So the second time you run the copy you don't even need the force switch and it will copy. Copy-Item definitely needs to be fixed in the way it handles files that already exist. -= IJuan =- "Gerd Schneider" wrote: > Keith, > > I played around a little bit with your example and found some more > surprising behavior. What about this: > > C:>'abc' > foo.dat > C:>type foo.dat > abc > C:>'xyz' > foo.new > C:>type foo.new > xyz > C:>(gi foo.dat).isreadonly=$true > C:>(gi foo.dat).isreadonly > True > C:>copy foo.new foo.dat -force > Copy-Item : The file 'C:\Documents and Settings\schneger\Local > Settings\Temp\foo.dat' already exists. > At line:1 char:5 > + copy <<<< foo.new foo.dat -force > C:>copy -force foo.new foo.dat > C:>type foo.dat > xyz > C:> > > -force is very well able to overwrite r/o files - depending on the placement > in the copy commandline. I agree, this looks like a serious bug in > commandline parsing. > > Gerd > > > "Keith Hill [MVP]" wrote: > > > I think I might have found a bug. The following command (3rd line) properly > > redirects the error stream to the file: > > > > copy-item *.ps1 c:\temp > > gci c:\temp\*.ps1 | %{$_.IsReadOnly = $true} > > copy-item *.ps1 c:\temp 2>&1 > foo.txt > > > > However if I now add -force, the error stream is no longer redirected to the > > file: > > > > copy-item *.ps1 c:\temp -force 2>&1 > foo.txt > > > > That's got to be a bug right? Never mind the fact that -force doesn't > > "force" the overwrite of a read-only file - grrr. BTW if you think > > that -force should allow overwrites of readonly files (like it does with > > UNIX cp -f), then vote on this issue at: > > > > https://connect.microsoft.com/feedba...3448&SiteID=99 > > > > -- > > Keith > > > > > > |
My System Specs![]() |
| | #4 (permalink) |
| | RE: Stderror redirect bug? I tried that. You're right. "IJuan" wrote: > If you read the link the Keith gave it states the the first time you run the > copy with the force switch and clears the readonly flag but doesn't actually > do the copy. So the second time you run the copy you don't even need the > force switch and it will copy. > > Copy-Item definitely needs to be fixed in the way it handles files that > already exist. > > > -= IJuan =- > > "Gerd Schneider" wrote: > > > Keith, > > > > I played around a little bit with your example and found some more > > surprising behavior. What about this: > > > > C:>'abc' > foo.dat > > C:>type foo.dat > > abc > > C:>'xyz' > foo.new > > C:>type foo.new > > xyz > > C:>(gi foo.dat).isreadonly=$true > > C:>(gi foo.dat).isreadonly > > True > > C:>copy foo.new foo.dat -force > > Copy-Item : The file 'C:\Documents and Settings\schneger\Local > > Settings\Temp\foo.dat' already exists. > > At line:1 char:5 > > + copy <<<< foo.new foo.dat -force > > C:>copy -force foo.new foo.dat > > C:>type foo.dat > > xyz > > C:> > > > > -force is very well able to overwrite r/o files - depending on the placement > > in the copy commandline. I agree, this looks like a serious bug in > > commandline parsing. > > > > Gerd > > > > > > "Keith Hill [MVP]" wrote: > > > > > I think I might have found a bug. The following command (3rd line) properly > > > redirects the error stream to the file: > > > > > > copy-item *.ps1 c:\temp > > > gci c:\temp\*.ps1 | %{$_.IsReadOnly = $true} > > > copy-item *.ps1 c:\temp 2>&1 > foo.txt > > > > > > However if I now add -force, the error stream is no longer redirected to the > > > file: > > > > > > copy-item *.ps1 c:\temp -force 2>&1 > foo.txt > > > > > > That's got to be a bug right? Never mind the fact that -force doesn't > > > "force" the overwrite of a read-only file - grrr. BTW if you think > > > that -force should allow overwrites of readonly files (like it does with > > > UNIX cp -f), then vote on this issue at: > > > > > > https://connect.microsoft.com/feedba...3448&SiteID=99 > > > > > > -- > > > Keith > > > > > > > > > |
My System Specs![]() |
| | #5 (permalink) |
| | Re: Stderror redirect bug? "Keith Hill [MVP]" <r_keith_hill@no.spam.thank.u.hotmail.com> wrote in message news:uKeIzhxkHHA.1776@TK2MSFTNGP05.phx.gbl... >I think I might have found a bug. The following command (3rd line) >properly redirects the error stream to the file: > > copy-item *.ps1 c:\temp > gci c:\temp\*.ps1 | %{$_.IsReadOnly = $true} > copy-item *.ps1 c:\temp 2>&1 > foo.txt > > However if I now add -force, the error stream is no longer redirected to > the file: > > copy-item *.ps1 c:\temp -force 2>&1 > foo.txt I submitted this defect. If you can validate it, please vote on it here: https://connect.microsoft.com/feedba...6933&SiteID=99 -- Keith |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Redirect all output | PowerShell | |||
| reading stderror stream | VB Script | |||
| IE redirect problem | Vista General | |||
| URL Redirect Problem | Vista General | |||
| Redirect of (my Documents) | Vista file management | |||