last day (15 days later) » 

sbi
2:07 PM
OK, let's use this one.
I want to recurse through a directory structure, and I am failing at that. :(
What I have is this: get-childitem $args[0] | foreach-object -process {ProcessPath($_)}
function ProcessPath($thePath)
{
  echo $thePath.PSPath

  if($thePath.PSPath.Exists)
  {
    echo $thePath.PSPath "does not exist!"
    return;
  }

  get-childitem $thePath | foreach-object -process {ProcessPath($_)}
}
 
get-childitem has a -recurse flag, I think.
 
sbi
I have first tried with .Name, rather than .PSPath, but that's empty.
@RMartinhoFernandes Oh.
yeah, damn
lemme look into that
Ok, that works.
However.
This fails: if(!$args[0].Exists)
Why?
@RMartinhoFernandes
 
Hmm, they use strange things for operators. It's probably not !.
 
sbi
Well, it's a string, so it won't work.
How do I get some pathInfo or something alike from that?
 
It's a string?
 
sbi
2:13 PM
@RMartinhoFernandes echo $args[0] | gm
TypeName: System.String
 
sbi
Not surprisingly.
 
get-item?
Hm, that will fail if it doesn't exist.
Ah, test-path.
 
sbi
Well, I do have this now again: get-childitem -recurse $args[0] | foreach-object -process {ProcessPath($_)}
function ProcessPath($thePath)
{
  echo $thePath
  echo $thePath | gm
}
This echo $thePath is equal to dir in DOS.
 
Ah, but that's expected.
echo produces strings.
 
sbi
2:18 PM
But I am trying to get at the stupid thing's path!
 
If you do gm $thePath it should work.
 
sbi
It's a System.IO.DirectoryInfo
 
echo is like calling ToString.
@sbi Ah, you want its name?
Weird, .Name should work.
(It works here)
 
sbi
@RMartinhoFernandes No, I want several of its properties. Just not its child items!
@RMartinhoFernandes It's $thePath | gm. Yours produces an error.
 
sbi
2:23 PM
afk
 
Ok, I need to clear some confusion. What type is $thePath? You mentioned a string before, but then you mentioned a DirectoryInfo.
 
sbi
2:37 PM
@RMartinhoFernandes Sorry, had to help a cow-worker to solve a crash issue in C++ code. It seems he confused if(initCounter++) ... (no lock or memory barrier) with thread-safety.
I am back now.
 
sbi
Well, $args[0] certainly is a string. But once I pass this into ProcessPath() as a result of get-childitem, then I get a System.IO.DirectoryInfo. (And then it is named $thePath.)
 
So, what is the type of $thePath?
@sbi So what's the problem then?
 
sbi
Note the diff: $args[0] and $thePath.
@RMartinhoFernandes Um.
 
$thePath.Exists and $thePath.Name (or $thePath.FullName) should do fine.
 
sbi
2:40 PM
I dunno. Now $thePath.Name produces something sensible.
 
sbi
All of a sudden. ;-/
Lemme progress to .Exists now...
Durn. Now it works! What did I do wrong?!
Ok, next step...
Ah, the damn thing won't give me .file starting with a dot...
 
Hm. Those are treated as hidden on Linux, but I thought Windows didn't give them any special treatment.
Hmm, a quick test on my machine gives me some .hgignore files I have.
Maybe with -force (if it is hidden)?
 
sbi
@RMartinhoFernandes Yep, I got that working.
I have now a script that recurses through a folder hierarchy and finds me all .svn items. (Those are folders that got pulled in via external references.)
Now I need to deal with those.
But first I need to get something to eat. I barely had breakfast, and I skipped lunch. It's 5pm now and those guys in my room look funny at me every time my belly growls.
afk
 
2:56 PM
@sbi Bon appétit :) I'll be around until late in the afternoon.
 
 
2 hours later…
sbi
4:30 PM
You still there, @RMartinho?
How do I format out put lines?
I want to output this: $thePath.Name in $thePath.Parent.FullName.
However, this creates newlines for each whitespace. :(
 
Concatenate the strings and echo them?
 
sbi
@RMartinhoFernandes How do I do that?
Concatenating, that is.
 
$result = $thePath.Name + " in " + $thePath.Parent.FullName?
 
sbi
@RMartinhoFernandes Oh, thanks. I tried to echo that directly, and it didn't work: echo $thePath.Name + " in " + $thePath.Parent.FullName.
 
Hmm, possibly needs parenthesis.
That thing is fiddly with that sometimes.
 
sbi
4:36 PM
@RMartinhoFernandes Indeed, parens work, too!
Now onto svn...
Mhhm. In a cmd window this works:
C:\Users\me>svn
Type 'svn help' for usage.

C:\Users\me>
In the PS shell, this does nuffink:
PS C:\Users\me> svn help
PS C:\Users\me>
What's with this, @RMartinho?
 
sbi
Woah?
 
Can't repro :/
 
sbi
Because you don't have svn?
 
I do.
> svn help prints the help message as expected.
 
sbi
4:41 PM
That doesn't do anything either!
PS C:\Users\me> cmd
PS C:\Users\me>
 
Restart that session? I am really at a loss here.
 
sbi
The PS just seems to ignore any command I pass it.
Is there some security thingie in this?
 
There is, but it should not make a difference here.
 
sbi
Strange. start cmd opens a cmd window.
 
That's expected behaviour.
 
sbi
4:45 PM
@RMartinhoFernandes Yeah. Well, at least I was certainly expecting that.
But why wouldn't cmd not start a cmd session?
 
Here it does.
But it's inside the same host.
C:\Users\rmf> cmd
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\rmf> exit

C:\Users\rmf>
 
sbi
4 mins ago, by R. Martinho Fernandes
Restart that session? I am really at a loss here.
Damn.
How did I mess this up so badly?
Whatever, on I plow...
Thanks for your help!
 
You're welcome.
 

last day (15 days later) »