Trying to compile a file and open it for edit if it fails or run it if it goes throughLooping through the content of a file in BashLooking for a bash script to run a program with different inputs on linux serverTransfer a file to remote machine(ubuntu) while running bash remotelyHow do I convert this bash loop to python?check if file is open with lsofHow does this perl one liner in the bash works?Bash - Compiling sleep loadableSimple bash scriptCreating self-executable node.js serverWriting to a file multiple times with Bash

How are mathematicians paid to do research?

How do we handle pauses in a dialogue?

What were the main German words for a prostitute before 1800?

Short story about Nobel Prize winning scientists that drop out when they realise they were incorrect

Why would non-kinetic weapons be used for orbital bombardment?

Why didn't Thanos kill all the Dwarves on Nidavellir?

Is a request to book a business flight ticket for a graduate student an unreasonable one?

Why does wrapping aluminium foil around my food help it keep warm, even though aluminium is a good conductor?

Can the Mage Hand cantrip be used to trip an enemy who is running away?

Is "I do not want you to go nowhere" a case of "DOUBLE-NEGATIVES" as claimed by Grammarly?

Swapping "Good" and "Bad"

Is there a strong legal guarantee that the U.S. can give to another country that it won't attack them?

Why is the ladder of the LM always in the dark side of the LM?

Is it correct to join training and validation set before inferring on test-set?

How do native German speakers usually express skepticism (using even) about a premise?

Which star / galaxy is moving away from us the fastest?

Addressing unnecessary daily meetings with manager?

Was I subtly told to resign?

How can I truly shut down ssh server?

Print the last, middle and first character of your code

If your plane is out-of-control, why does military training instruct releasing the joystick to neutralize controls?

Misspelling my name on my mathematical publications

Is "De qui parles-tu" (for example) as formal as it is in English, or is it normal for the French to casually say that

Credit score and financing new car



Trying to compile a file and open it for edit if it fails or run it if it goes through


Looping through the content of a file in BashLooking for a bash script to run a program with different inputs on linux serverTransfer a file to remote machine(ubuntu) while running bash remotelyHow do I convert this bash loop to python?check if file is open with lsofHow does this perl one liner in the bash works?Bash - Compiling sleep loadableSimple bash scriptCreating self-executable node.js serverWriting to a file multiple times with Bash






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















So I have written this line of Bash



rustc hello.rs && ./hello || ( exit_on_error sleep 10s ; vi hello.rs )


The goal is that I compile the file. If compilation is successful it should run the script. If not it should give me 10 seconds to read the error before opening the file for edit again.



I have been having trouble getting the sleep and the edit to happen sequentially and only when the compilation fails. I cant figure out what type of bracket to use. In this version if compilation fails it immediately opens the file for edit.



How can I achieve the desired result here?










share|improve this question






















  • Regarding "I cant figure out what type of bracket to use", the ( ) you're using creates a subshell, which is probably not what you want. is simply a grouping operator. See The Bash Manual.

    – dimo414
    Apr 7 at 23:30

















0















So I have written this line of Bash



rustc hello.rs && ./hello || ( exit_on_error sleep 10s ; vi hello.rs )


The goal is that I compile the file. If compilation is successful it should run the script. If not it should give me 10 seconds to read the error before opening the file for edit again.



I have been having trouble getting the sleep and the edit to happen sequentially and only when the compilation fails. I cant figure out what type of bracket to use. In this version if compilation fails it immediately opens the file for edit.



How can I achieve the desired result here?










share|improve this question






















  • Regarding "I cant figure out what type of bracket to use", the ( ) you're using creates a subshell, which is probably not what you want. is simply a grouping operator. See The Bash Manual.

    – dimo414
    Apr 7 at 23:30













0












0








0








So I have written this line of Bash



rustc hello.rs && ./hello || ( exit_on_error sleep 10s ; vi hello.rs )


The goal is that I compile the file. If compilation is successful it should run the script. If not it should give me 10 seconds to read the error before opening the file for edit again.



I have been having trouble getting the sleep and the edit to happen sequentially and only when the compilation fails. I cant figure out what type of bracket to use. In this version if compilation fails it immediately opens the file for edit.



How can I achieve the desired result here?










share|improve this question














So I have written this line of Bash



rustc hello.rs && ./hello || ( exit_on_error sleep 10s ; vi hello.rs )


The goal is that I compile the file. If compilation is successful it should run the script. If not it should give me 10 seconds to read the error before opening the file for edit again.



I have been having trouble getting the sleep and the edit to happen sequentially and only when the compilation fails. I cant figure out what type of bracket to use. In this version if compilation fails it immediately opens the file for edit.



How can I achieve the desired result here?







bash






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 26 at 1:28









CalebKCalebK

758 bronze badges




758 bronze badges












  • Regarding "I cant figure out what type of bracket to use", the ( ) you're using creates a subshell, which is probably not what you want. is simply a grouping operator. See The Bash Manual.

    – dimo414
    Apr 7 at 23:30

















  • Regarding "I cant figure out what type of bracket to use", the ( ) you're using creates a subshell, which is probably not what you want. is simply a grouping operator. See The Bash Manual.

    – dimo414
    Apr 7 at 23:30
















Regarding "I cant figure out what type of bracket to use", the ( ) you're using creates a subshell, which is probably not what you want. is simply a grouping operator. See The Bash Manual.

– dimo414
Apr 7 at 23:30





Regarding "I cant figure out what type of bracket to use", the ( ) you're using creates a subshell, which is probably not what you want. is simply a grouping operator. See The Bash Manual.

– dimo414
Apr 7 at 23:30












1 Answer
1






active

oldest

votes


















2














I wouldn't waste time trying to understand the interactions of multiple sequential && and || operations (especially not in a mixture — all the same is OK). I'd just write it cleanly:



if rustc hello.rs
then ./hello
else sleep 10s; vi hello.rs
fi


which can be flattened onto a single line with:



if rustc hello.rs; then ./hello; else sleep 10s; vi hello.rs; fi


But I'd make it into a script which takes the file name(s) as arguments and processes them, etc, with environment variables to adjust the compiler and options too.






share|improve this answer






















    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    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%2fstackoverflow.com%2fquestions%2f55348617%2ftrying-to-compile-a-file-and-open-it-for-edit-if-it-fails-or-run-it-if-it-goes-t%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    2














    I wouldn't waste time trying to understand the interactions of multiple sequential && and || operations (especially not in a mixture — all the same is OK). I'd just write it cleanly:



    if rustc hello.rs
    then ./hello
    else sleep 10s; vi hello.rs
    fi


    which can be flattened onto a single line with:



    if rustc hello.rs; then ./hello; else sleep 10s; vi hello.rs; fi


    But I'd make it into a script which takes the file name(s) as arguments and processes them, etc, with environment variables to adjust the compiler and options too.






    share|improve this answer



























      2














      I wouldn't waste time trying to understand the interactions of multiple sequential && and || operations (especially not in a mixture — all the same is OK). I'd just write it cleanly:



      if rustc hello.rs
      then ./hello
      else sleep 10s; vi hello.rs
      fi


      which can be flattened onto a single line with:



      if rustc hello.rs; then ./hello; else sleep 10s; vi hello.rs; fi


      But I'd make it into a script which takes the file name(s) as arguments and processes them, etc, with environment variables to adjust the compiler and options too.






      share|improve this answer

























        2












        2








        2







        I wouldn't waste time trying to understand the interactions of multiple sequential && and || operations (especially not in a mixture — all the same is OK). I'd just write it cleanly:



        if rustc hello.rs
        then ./hello
        else sleep 10s; vi hello.rs
        fi


        which can be flattened onto a single line with:



        if rustc hello.rs; then ./hello; else sleep 10s; vi hello.rs; fi


        But I'd make it into a script which takes the file name(s) as arguments and processes them, etc, with environment variables to adjust the compiler and options too.






        share|improve this answer













        I wouldn't waste time trying to understand the interactions of multiple sequential && and || operations (especially not in a mixture — all the same is OK). I'd just write it cleanly:



        if rustc hello.rs
        then ./hello
        else sleep 10s; vi hello.rs
        fi


        which can be flattened onto a single line with:



        if rustc hello.rs; then ./hello; else sleep 10s; vi hello.rs; fi


        But I'd make it into a script which takes the file name(s) as arguments and processes them, etc, with environment variables to adjust the compiler and options too.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 26 at 1:50









        Jonathan LefflerJonathan Leffler

        586k96 gold badges706 silver badges1056 bronze badges




        586k96 gold badges706 silver badges1056 bronze badges


















            Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







            Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • 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%2fstackoverflow.com%2fquestions%2f55348617%2ftrying-to-compile-a-file-and-open-it-for-edit-if-it-fails-or-run-it-if-it-goes-t%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

            Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

            Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

            Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript