You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@nuttx.apache.org by Mike Mogenson <mi...@gmail.com> on 2022/08/10 05:52:22 UTC

How to ignore preceding "./" (dot slash) for paths in NSH

Can I configure NSH (or the fs driver) to ignore preceding "./“ (dot
slash) characters when reading directories or opening files?

For example, the following does not work in NSH:

```
nsh> echo "hello" > hello.txt
nsh> ls .
/sd:
 hello.txt
nsh> ls ./
nsh: ls: stat failed: 2
nsh> cat hello.txt
hello
nsh> cat ./hello.txt
nsh: cat: open failed: 20
```

I believe POSIX compatible shells in Unix allow this.

The reason I ask is because part of the default module search path in
the Lua interpreter is "./?lua" and "./?/init.lua”.  This will try to
open a “./foo.lua” or “./foo/init.lua” file for a “foo =
require(‘foo’)” statement. This currently fails because of the
preceding dot slash. I can patch the default module search path when
building Lua for NuttX. But I prefer to keep the behavior of the Lua
interpreter consistent across desktop and NuttX.