Coder Social home page Coder Social logo

When, and how, to use xargs about bashstyle HOT 5 OPEN

progrium avatar progrium commented on August 30, 2024
When, and how, to use xargs

from bashstyle.

Comments (5)

stuartpb avatar stuartpb commented on August 30, 2024

Also, this is one of those places where a novice Basher may be tempted to use eval. Never use eval. Not only would it be opening yourself up to arbitrary code execution, it'd do the wrong thing: if someone passes ; exit 1 to a command that's going to append its arguments to an init script, passing this to eval would cause those to be interpreted as part of the command to be evaluated. This is why you let xargs interpret the arguments.

from bashstyle.

progrium avatar progrium commented on August 30, 2024

Can you write something up on this? I'm not actually as familiar. Along with this, it could be nice to have a few useful patterns to showcase xargs.

from bashstyle.

stuartpb avatar stuartpb commented on August 30, 2024

The two best examples off the top of my head:

from bashstyle.

stuartpb avatar stuartpb commented on August 30, 2024

I think I wrote a few things on this in the issues for sshcommand. Basically the -x option to xargs tells it that we're constructing a single call (xargs is built to split very long streams into multiple calls by default), which should fail if it exceeds the size of a single call. (-x may also use an exec-like call to execute as a tail call, I'm not sure.) The -a option allows you to specify the arguments as a file (or a redirected process), so that STDIN can be inherited by the called function (if you use STDIN to specify the call's arguments, the launched process will get /dev/null as its STDIN).

from bashstyle.

progrium avatar progrium commented on August 30, 2024

I'm saying, can you write a little mini-guide on xarg patterns?

from bashstyle.

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.