chain Fish commands via `&&` or `||`












90















In Bash/ZSH and other shells, I am used to using && and ||.



Is there any equivalent in Fish?










share|improve this question























  • This syntax now supported on the master branch and will be released in Fish 3.0 (github.com/fish-shell/fish-shell/commit/…)

    – Clever Little Monkey
    Mar 29 '18 at 1:31


















90















In Bash/ZSH and other shells, I am used to using && and ||.



Is there any equivalent in Fish?










share|improve this question























  • This syntax now supported on the master branch and will be released in Fish 3.0 (github.com/fish-shell/fish-shell/commit/…)

    – Clever Little Monkey
    Mar 29 '18 at 1:31
















90












90








90


28






In Bash/ZSH and other shells, I am used to using && and ||.



Is there any equivalent in Fish?










share|improve this question














In Bash/ZSH and other shells, I am used to using && and ||.



Is there any equivalent in Fish?







shell fish






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jul 10 '12 at 3:01









AlbertAlbert

2,83463043




2,83463043













  • This syntax now supported on the master branch and will be released in Fish 3.0 (github.com/fish-shell/fish-shell/commit/…)

    – Clever Little Monkey
    Mar 29 '18 at 1:31





















  • This syntax now supported on the master branch and will be released in Fish 3.0 (github.com/fish-shell/fish-shell/commit/…)

    – Clever Little Monkey
    Mar 29 '18 at 1:31



















This syntax now supported on the master branch and will be released in Fish 3.0 (github.com/fish-shell/fish-shell/commit/…)

– Clever Little Monkey
Mar 29 '18 at 1:31







This syntax now supported on the master branch and will be released in Fish 3.0 (github.com/fish-shell/fish-shell/commit/…)

– Clever Little Monkey
Mar 29 '18 at 1:31












2 Answers
2






active

oldest

votes


















7














The logical operators you're used to, are supported since fish 3.0.0, released on 2018-12-28.



From the v3 release notes:





  • fish now supports && (like and), || (like or), and ! (like not), for better migration from POSIX-compliant shells (#4620).







share|improve this answer































    126














    Fish doesn't have a special syntax for a logical AND (&&) or a logical OR (||).



    Instead, you can use the commands and and or, which verify the previous command's exit status and act accordingly:



    command1
    and command2




    command1
    or command2


    Furthermore – just like in bash – you can use a semicolon ; to execute two commands one after the other:



    command1 ; command2


    This allows using a more familiar syntax:



    command1 ;and command2
    command1 ;or command2


    See http://fishshell.com/docs/current/tutorial.html#tut_combiners






    share|improve this answer





















    • 4





      There's an open github issue to add support for this syntax: && doesn't work · Issue #150 · fish-shell/fish-shell

      – aboy021
      Feb 26 '16 at 0:41








    • 20





      This allows using a more familiar syntax: is very subjective

      – Petr Peller
      Jun 2 '16 at 10:46






    • 1





      ;and is less readable than && as the semicolon suggests a logically disjoint operation. It's visually jarring.

      – Clever Little Monkey
      Jul 30 '17 at 20:08













    • @Elliott I agree, but Fish doesn't give you a choice.

      – Dennis
      Jul 30 '17 at 20:11






    • 1





      do note though that in fish and bourne shells, AND and OR operators have the same order, unlike C based languages: unix.stackexchange.com/a/88851/50703

      – balupton
      Jan 11 '18 at 8:31











    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "3"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f446930%2fchain-fish-commands-via-or%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    7














    The logical operators you're used to, are supported since fish 3.0.0, released on 2018-12-28.



    From the v3 release notes:





    • fish now supports && (like and), || (like or), and ! (like not), for better migration from POSIX-compliant shells (#4620).







    share|improve this answer




























      7














      The logical operators you're used to, are supported since fish 3.0.0, released on 2018-12-28.



      From the v3 release notes:





      • fish now supports && (like and), || (like or), and ! (like not), for better migration from POSIX-compliant shells (#4620).







      share|improve this answer


























        7












        7








        7







        The logical operators you're used to, are supported since fish 3.0.0, released on 2018-12-28.



        From the v3 release notes:





        • fish now supports && (like and), || (like or), and ! (like not), for better migration from POSIX-compliant shells (#4620).







        share|improve this answer













        The logical operators you're used to, are supported since fish 3.0.0, released on 2018-12-28.



        From the v3 release notes:





        • fish now supports && (like and), || (like or), and ! (like not), for better migration from POSIX-compliant shells (#4620).








        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jan 1 at 23:18









        DennisDennis

        272412




        272412

























            126














            Fish doesn't have a special syntax for a logical AND (&&) or a logical OR (||).



            Instead, you can use the commands and and or, which verify the previous command's exit status and act accordingly:



            command1
            and command2




            command1
            or command2


            Furthermore – just like in bash – you can use a semicolon ; to execute two commands one after the other:



            command1 ; command2


            This allows using a more familiar syntax:



            command1 ;and command2
            command1 ;or command2


            See http://fishshell.com/docs/current/tutorial.html#tut_combiners






            share|improve this answer





















            • 4





              There's an open github issue to add support for this syntax: && doesn't work · Issue #150 · fish-shell/fish-shell

              – aboy021
              Feb 26 '16 at 0:41








            • 20





              This allows using a more familiar syntax: is very subjective

              – Petr Peller
              Jun 2 '16 at 10:46






            • 1





              ;and is less readable than && as the semicolon suggests a logically disjoint operation. It's visually jarring.

              – Clever Little Monkey
              Jul 30 '17 at 20:08













            • @Elliott I agree, but Fish doesn't give you a choice.

              – Dennis
              Jul 30 '17 at 20:11






            • 1





              do note though that in fish and bourne shells, AND and OR operators have the same order, unlike C based languages: unix.stackexchange.com/a/88851/50703

              – balupton
              Jan 11 '18 at 8:31
















            126














            Fish doesn't have a special syntax for a logical AND (&&) or a logical OR (||).



            Instead, you can use the commands and and or, which verify the previous command's exit status and act accordingly:



            command1
            and command2




            command1
            or command2


            Furthermore – just like in bash – you can use a semicolon ; to execute two commands one after the other:



            command1 ; command2


            This allows using a more familiar syntax:



            command1 ;and command2
            command1 ;or command2


            See http://fishshell.com/docs/current/tutorial.html#tut_combiners






            share|improve this answer





















            • 4





              There's an open github issue to add support for this syntax: && doesn't work · Issue #150 · fish-shell/fish-shell

              – aboy021
              Feb 26 '16 at 0:41








            • 20





              This allows using a more familiar syntax: is very subjective

              – Petr Peller
              Jun 2 '16 at 10:46






            • 1





              ;and is less readable than && as the semicolon suggests a logically disjoint operation. It's visually jarring.

              – Clever Little Monkey
              Jul 30 '17 at 20:08













            • @Elliott I agree, but Fish doesn't give you a choice.

              – Dennis
              Jul 30 '17 at 20:11






            • 1





              do note though that in fish and bourne shells, AND and OR operators have the same order, unlike C based languages: unix.stackexchange.com/a/88851/50703

              – balupton
              Jan 11 '18 at 8:31














            126












            126








            126







            Fish doesn't have a special syntax for a logical AND (&&) or a logical OR (||).



            Instead, you can use the commands and and or, which verify the previous command's exit status and act accordingly:



            command1
            and command2




            command1
            or command2


            Furthermore – just like in bash – you can use a semicolon ; to execute two commands one after the other:



            command1 ; command2


            This allows using a more familiar syntax:



            command1 ;and command2
            command1 ;or command2


            See http://fishshell.com/docs/current/tutorial.html#tut_combiners






            share|improve this answer















            Fish doesn't have a special syntax for a logical AND (&&) or a logical OR (||).



            Instead, you can use the commands and and or, which verify the previous command's exit status and act accordingly:



            command1
            and command2




            command1
            or command2


            Furthermore – just like in bash – you can use a semicolon ; to execute two commands one after the other:



            command1 ; command2


            This allows using a more familiar syntax:



            command1 ;and command2
            command1 ;or command2


            See http://fishshell.com/docs/current/tutorial.html#tut_combiners







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Oct 12 '14 at 5:31









            lindhe

            140214




            140214










            answered Jul 10 '12 at 3:18









            DennisDennis

            40.5k6101136




            40.5k6101136








            • 4





              There's an open github issue to add support for this syntax: && doesn't work · Issue #150 · fish-shell/fish-shell

              – aboy021
              Feb 26 '16 at 0:41








            • 20





              This allows using a more familiar syntax: is very subjective

              – Petr Peller
              Jun 2 '16 at 10:46






            • 1





              ;and is less readable than && as the semicolon suggests a logically disjoint operation. It's visually jarring.

              – Clever Little Monkey
              Jul 30 '17 at 20:08













            • @Elliott I agree, but Fish doesn't give you a choice.

              – Dennis
              Jul 30 '17 at 20:11






            • 1





              do note though that in fish and bourne shells, AND and OR operators have the same order, unlike C based languages: unix.stackexchange.com/a/88851/50703

              – balupton
              Jan 11 '18 at 8:31














            • 4





              There's an open github issue to add support for this syntax: && doesn't work · Issue #150 · fish-shell/fish-shell

              – aboy021
              Feb 26 '16 at 0:41








            • 20





              This allows using a more familiar syntax: is very subjective

              – Petr Peller
              Jun 2 '16 at 10:46






            • 1





              ;and is less readable than && as the semicolon suggests a logically disjoint operation. It's visually jarring.

              – Clever Little Monkey
              Jul 30 '17 at 20:08













            • @Elliott I agree, but Fish doesn't give you a choice.

              – Dennis
              Jul 30 '17 at 20:11






            • 1





              do note though that in fish and bourne shells, AND and OR operators have the same order, unlike C based languages: unix.stackexchange.com/a/88851/50703

              – balupton
              Jan 11 '18 at 8:31








            4




            4





            There's an open github issue to add support for this syntax: && doesn't work · Issue #150 · fish-shell/fish-shell

            – aboy021
            Feb 26 '16 at 0:41







            There's an open github issue to add support for this syntax: && doesn't work · Issue #150 · fish-shell/fish-shell

            – aboy021
            Feb 26 '16 at 0:41






            20




            20





            This allows using a more familiar syntax: is very subjective

            – Petr Peller
            Jun 2 '16 at 10:46





            This allows using a more familiar syntax: is very subjective

            – Petr Peller
            Jun 2 '16 at 10:46




            1




            1





            ;and is less readable than && as the semicolon suggests a logically disjoint operation. It's visually jarring.

            – Clever Little Monkey
            Jul 30 '17 at 20:08







            ;and is less readable than && as the semicolon suggests a logically disjoint operation. It's visually jarring.

            – Clever Little Monkey
            Jul 30 '17 at 20:08















            @Elliott I agree, but Fish doesn't give you a choice.

            – Dennis
            Jul 30 '17 at 20:11





            @Elliott I agree, but Fish doesn't give you a choice.

            – Dennis
            Jul 30 '17 at 20:11




            1




            1





            do note though that in fish and bourne shells, AND and OR operators have the same order, unlike C based languages: unix.stackexchange.com/a/88851/50703

            – balupton
            Jan 11 '18 at 8:31





            do note though that in fish and bourne shells, AND and OR operators have the same order, unlike C based languages: unix.stackexchange.com/a/88851/50703

            – balupton
            Jan 11 '18 at 8:31


















            draft saved

            draft discarded




















































            Thanks for contributing an answer to Super User!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f446930%2fchain-fish-commands-via-or%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            flock() on closed filehandle LOCK_FILE at /usr/bin/apt-mirror

            Mangá

             ⁒  ․,‪⁊‑⁙ ⁖, ⁇‒※‌, †,⁖‗‌⁝    ‾‸⁘,‖⁔⁣,⁂‾
”‑,‥–,‬ ,⁀‹⁋‴⁑ ‒ ,‴⁋”‼ ⁨,‷⁔„ ‰′,‐‚ ‥‡‎“‷⁃⁨⁅⁣,⁔
⁇‘⁔⁡⁏⁌⁡‿‶‏⁨ ⁣⁕⁖⁨⁩⁥‽⁀  ‴‬⁜‟ ⁃‣‧⁕‮ …‍⁨‴ ⁩,⁚⁖‫ ,‵ ⁀,‮⁝‣‣ ⁑  ⁂– ․, ‾‽ ‏⁁“⁗‸ ‾… ‹‡⁌⁎‸‘ ‡⁏⁌‪ ‵⁛ ‎⁨ ―⁦⁤⁄⁕