File tree Expand file tree Collapse file tree 2 files changed +8
-4
lines changed
core/src/main/scala/io/chrisdavenport/shellfish Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -139,6 +139,7 @@ trait Shell[F[_]]{
139
139
/** Show all matching executables in PATH, not just the first */
140
140
def whichAll (path : String ): Stream [F , String ]
141
141
142
+ def ls : Stream [F , String ]
142
143
def ls (path : String ): Stream [F , String ]
143
144
}
144
145
@@ -208,8 +209,9 @@ object Shell {
208
209
209
210
def cd (path : String ): F [Unit ] = for {
210
211
newPath <- getResolved(path)
211
- out <- files.isDirectory(newPath).ifM(
212
- setWd(newPath.toAbsolutePath.toString),
212
+ real = newPath.toRealPath()
213
+ out <- files.isDirectory(real).ifM(
214
+ setWd(real.toString),
213
215
new RuntimeException (s " cd: no such file or directory $path" ).raiseError
214
216
)
215
217
} yield out
@@ -306,9 +308,10 @@ object Shell {
306
308
.map(_.toString)
307
309
)
308
310
311
+ def ls : Stream [F , String ] = ls(" " )
309
312
def ls (path : String ): Stream [F , String ] =
310
313
Stream .eval(getResolved(path)).flatMap(p =>
311
- files.walk(p, 1 ).map(_.toString)
314
+ files.walk(p, 1 ).map(_.toString).drop( 1 ) // Exclude Myself
312
315
)
313
316
314
317
}
Original file line number Diff line number Diff line change @@ -21,7 +21,8 @@ object Main extends IOApp {
21
21
// got <- p.shellStrict("find", List("-wholename", "*.scala"))
22
22
// got <- which("java")
23
23
// got <- hostname
24
- got <- ls(" " ).compile.toList
24
+ _ <- cd(" .." )
25
+ got <- ls.compile.toList
25
26
_ <- echo(got.toString)
26
27
// _ <- p.shellStrict("which", "java":: Nil).flatMap(a => echo(a.toString))
27
28
} yield ExitCode .Success
You can’t perform that action at this time.
0 commit comments