Comments (5)
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.
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.
The two best examples off the top of my head:
- How Plushu handles being started as a shell with
plushu -c <command>
: https://github.com/plushu/plushu/blob/master/bin/plushush#L5 - How plushu-deploy-app-local-container integrates Docker arguments it gets from a hook: https://github.com/plushu/plushu-deploy-app-local-container/blob/master/hooks/deploy-app#L21-23
from bashstyle.
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.
I'm saying, can you write a little mini-guide on xarg patterns?
from bashstyle.
Related Issues (20)
- Why to always use "if [[ ... ]]; then; fi" instead of a conditional statement HOT 7
- Tabs are not evil! HOT 11
- Use curly braces for all variable references HOT 6
- Use [[ -n "$whatever" ]] rather than [[ "$whatever" ]] HOT 2
- Use `command -v` instead of `which` &c HOT 5
- Locale independence HOT 1
- Throwing `set -a` and `set +a` around a variable pair list HOT 2
- Using defaults and "${VAR:?}" HOT 3
- Ownership and modes HOT 1
- Tracing and Debugging HOT 2
- Mention shellcheck HOT 3
- support for differences when considering zsh/sh compatibility? HOT 2
- Guidance on documenting functions HOT 7
- set -u HOT 1
- Example of "This can be queried/extracted with a simple function using reflection." HOT 2
- Google's Bash styleguide link is broken HOT 2
- [discuss] Suffix all bash scripts with .sh
- Article reference link appears broken.
- Add license information
- Coverage
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bashstyle.