Giter Site home page Giter Site logo

Comments (1)

faho avatar faho commented on June 16, 2024 1

No, you need to pass the outer argument with quotes.

This works:

function ytd
    youtube-dl -t $argv[1]
end

ytd "https://youtu.be/HPGvrxjT7aY?si=94x7gGDp76rTI4dX"

You need to quote the argument where the string is - the ? is special, so that needs to be quoted where it is, not later.

That will work but I was hoping to be able to pass the argument without quotes, to have the function add them. Is this possible?

It is not. The argument is expanded before the function ever runs.

You can fiddle something together with abbreviations, which is a lot easier with abbr --command ( #10452):

function quote_arg
    string escape -- $argv
end

function ytd
    youtube-dl $argv
end

abbr -a --command ytd --function 'quote_arg' --regex '.*' quotearg

(without that you'll have to mess with commandline to check if it's an argument to ytd)

But in general, quoting is a fact of life. You cannot ignore quoting, the entire language is based on expansion - if it sees an unquoted $, it'll try to expand a variable, if it sees an unquoted *, it'll glob, if it sees an unquoted ; it'll end the command.

For ? in particular, we're removing it, and it's removed-by-default in the next release, so urls usually won't have special characters in them anymore.

from fish-shell.

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.