dart-lang / sdk

The Dart SDK, including the VM, JS and Wasm compilers, analysis, core libraries, and more.
https://dart.dev
BSD 3-Clause "New" or "Revised" License
10.25k stars 1.58k forks source link

Provide python-like os.path.expanduser and os.path.expandvars #18466

Open kevmoo opened 10 years ago

kevmoo commented 10 years ago

I naively use ~/tmp_output or similar a lot across commands.

But when I try with Dart commands, I end up creating a '~' directory in the working directory -- hilariously followed by a quite naive 'rm -rf ~'. A really great morning.

It'd be good to make it trivial to use standard path notation in the shell.

Python's implementations look like great inspiration

https://docs.python.org/2/library/os.path.html#os.path.expanduser https://docs.python.org/2/library/os.path.html#os.path.expandvars

This is related to https://code.google.com/p/dart/issues/detail?id=2930 for VM command line options

Perhaps we could hack this together in pkg/path -- but I feel it belongs in dart:io. Platform, perhaps?

nex3 commented 10 years ago

I agree that this should be part of dart:io, since the rules for expanding path shorthand very system-dependent and often complicated.

kevmoo commented 10 years ago

Removed Area-IO label. Added Library-IO label.

brianquinlan commented 1 year ago

I'm calling this a P3 because it is possible for Dart developers to implement this themselves or for it to be implemented as a separate package.

eseidel commented 1 year ago

Ran into this again today. It feels like something from an official Dart library should provide some way to expand ~ in a path since on Mac/Linux that's a common shorthand. But maybe it's not as common as I think?