Skip to content

Make Start-Sleep accept fractional seconds #8477

@mklement0

Description

@mklement0

Summary of the new feature/enhancement

While Start-Sleep -MilliSeconds offers fine-grained control over the sleep duration, it would be convenient not to have two switch parameters just to be able to effectively specify fractional seconds.

E.g., instead of:

Start-Sleep -MilliSeconds 1400

it would be nice to be able to write:

Start-Sleep 1.4  # wishful thinking; translate into 1,400 msecs.

This is in line with the sleep utility on macOS and Linux, which accepts fractional values (e.g., sleep 1.4)

Currently, fractional values are quietly converted to [int] values, which means that rounding is applied, which is not only obscure behavior, but behavior that existing code is unlikely to rely upon.

As an aside: Start-Sleep is misnamed and should be called Invoke-Sleep - see #3990.

Proposed technical implementation details (optional)

Change the data type of the -Seconds parameter from [int] to [double] and simply cast the internal conversion to milliseconds to (int).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Discussionthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifResolution-FixedThe issue is fixed.Up-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Cmdlets-Utilitycmdlets in the Microsoft.PowerShell.Utility module

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions