Skip to content

Commit cdf0f21

Browse files
Merge pull request #141 from Shopify/just-absolutize
Don't explode when expand-path result is missing
2 parents 5e07f9e + 1baec35 commit cdf0f21

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

docs/shadowlisp.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,8 @@ This can be especially useful in the sort of usage shown to the right.
228228
(expand-path "./bin") ; "/Users/you/src/project/bin"
229229
```
230230

231-
`expand-path` resolves a path to a canonicalized path, resolving any symlinks, relative references
232-
from the present working directory, and `~`.
231+
`expand-path` resolves a path to a canonicalized path, resolving relative references
232+
from the present working directory and `~`.
233233

234234
| Argument | Type | Description |
235235
|---|---|---|

man/man5/shadowlisp.5

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,8 @@ It's occasionally useful to take a subdirectory of a path found from some other
147147

148148
.SS \fB(expand-path \fIpath\fB)\fR
149149

150-
\fBexpand-path\fR resolves a path to a canonicalized path, resolving any symlinks, relative references
151-
from the present working directory, and \fB~\fR.
150+
\fBexpand-path\fR resolves a path to a canonicalized path, resolving relative references
151+
from the present working directory and \fB~\fR.
152152

153153
.TP
154154
\fBpath\fR

src/lang.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use ketos::{Context, Error, FromValueRef, Name, Value};
66
use ketos_derive::{ForeignValue, FromValueRef};
77
use std::{
88
cell::{Ref, RefCell},
9-
env, fs,
9+
env,
1010
path::{Path, PathBuf},
1111
rc::Rc,
1212
};
@@ -240,7 +240,7 @@ impl ShadowLang {
240240
assert_args!(args, 1, name);
241241
let path = <&str as FromValueRef>::from_value_ref(&args[0])?;
242242
let expanded = shellexpand::tilde(path);
243-
let canonicalized = match fs::canonicalize(expanded.to_string()) {
243+
let absolutized = match std::path::absolute(expanded.to_string()) {
244244
Ok(p) => p,
245245
Err(e) => {
246246
return Err(From::from(ketos::io::IoError {
@@ -251,7 +251,7 @@ impl ShadowLang {
251251
}
252252
};
253253
Ok(<String as Into<Value>>::into(
254-
canonicalized.to_string_lossy().to_string(),
254+
absolutized.to_string_lossy().to_string(),
255255
))
256256
})
257257
});

0 commit comments

Comments
 (0)