Giter Site home page Giter Site logo

Comments (8)

joelim-work avatar joelim-work commented on June 13, 2024 1

To provide some context, lf (a file manager) has a command line where text can be sent to a shell for execution. The following lines of code show how the shell arguments are built: https://github.com/gokcehan/lf/blob/0c02239b177a14526b84df41a07405c685cedaba/os.go#L142-L146

The resulting invocation looks roughly like this:

<shell> -c <script_contents> -- [args]...

This works nicely for POSIX-compliant shells, but not for nushell. I am not sure about the motivation however, since I think this doesn't fall under 'normal usage' requirements.

from nushell.

NotTheDr01ds avatar NotTheDr01ds commented on June 13, 2024 1

Ran into some similar problems with fzf passing a preview command-line to nu. In that case, it was differences in quoting between POSIX/Fish vs. Nushell.

I think there's a case to be made for providing some commonality with other shells in the way Nushell is invoked at least.

from nushell.

fdncred avatar fdncred commented on June 13, 2024 1

The last time we talked about this I thought that def --wrapped custom commands would suffice. I could be remembering wrong though. For what it's worth, I'd probably support something like nu -c 'echo $argv' -- foo bar because it's pretty widely used, although others may not.

Also, saying posix shells do x is not a real motivating factor for nushell to do anything since we have never planned on being posix compliant. However, we do want nushell to feel comfortable and "at home" to a certain degree, but that definitely doesn't mean implementing everything a posix shell does. Sometimes keeping muscle memory is good. Other times we should just learn something new.

This is how def --wrapped works. It allows you to pass most anything through

 def --wrapped test [...args] { print ...$args }
 test -- a b c
--
a
b
c

from nushell.

klesh avatar klesh commented on June 13, 2024 1

@fdncred Sure, I didn't mean that nushell should obey the posix standard, I believe it is too old and should have been renewed a long time ago.
My feeling is more like: look, even good old Posix shell has it covered 😄, and nushell doesn't seem to be supporting such a use case at all.

I may not understand the def --wrapped correctly, but it doesn't seem to be working:
image

So, I think we all agree that it is a good thing to have, I will be working on the feature maybe next week, it could take a while since I am new to the project and Rust 😄

from nushell.

fdncred avatar fdncred commented on June 13, 2024 1

Ok, as long as it doesn't interfere with params being passed to scripts. I'm pretty sure this is allowed now like nu script.nu param1 param2 where param1 and param2 are passed into script.nu as parameters. I could be remembering wrong though. Seems like it wouldn't interfere, but we just don't want to break existing functionality.

from nushell.

klesh avatar klesh commented on June 13, 2024

@fdncred Would you like to take a look at the issue and share your thoughts? I would like to work on it if we are on the same page.

from nushell.

fdncred avatar fdncred commented on June 13, 2024

You're trying to pass -- foo bar to nu, not the tmp custom command which is fine, but my example was for custom commands supporting those flags, not the nushell executable. The nushell executable does not support it and it would have to be added via rust code.

from nushell.

klesh avatar klesh commented on June 13, 2024

@fdncred Yes, you are correct. I just wanted to make sure we are on the same page. I would try to add the support to the double dash -- for the nu executable, and the temp custom command example you showed is a good pointer for the implementation.

from nushell.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.