2

Today I had to use Start-Sleep many times so I thought I would create a shortcut function for it, sleep($time). However, whenever I entered the function it never exits! It must be an issue with either the data type for the argument for Start-Sleep or the way I am declaring the function. Instead of posting the whole script, I've posted this useless one that would make a familiar beep pattern if it worked:

function beep {
    Write-Host `a
}

function sleep {

    param([int]$time)

    Start-Sleep -m $time
}

beep
sleep(300)
beep
sleep(200)
beep
sleep(50)
beep
sleep(300)
beep
sleep(450)
beep
sleep(200)
beep
tacos_tacos_tacos
  • 3,250
  • 18
  • 63
  • 100

1 Answers1

4

My system already has an alias for Start-Sleep called, oddly enough, sleep. run this to see if you have it dir alias:sleep. Try a different name for your function to see if that helps.

uSlackr
  • 6,412
  • 21
  • 37
  • I would just add that order of commands causes that alias sleep takes precedence before function sleep - thus you would eventually get your prompt back (after 300 secs in first run). – BartekB Jun 06 '12 at 21:11
  • I never thought about the fact that `sleep` might already be defined. Nice catch – tacos_tacos_tacos Jun 06 '12 at 21:47