Comments (4)
@ohnonot thank you for looking at the code, and for your suggestion.
I'm not quite sure, though, whether the use of curly brackets will actually make the difference the manuals suggest. skel/.config/bunsen/autostart is run from sh not bash, and the following tests were done in a shell (dash) environment, launched from a bash terminal (hence the bash process). However, the same results were seen running in bash too, ie there are two shells running in both cases:
$ ( sleep 2; echo OK; ) & ps
PID TTY TIME CMD
15071 pts/1 00:00:00 bash
15305 pts/1 00:00:00 sh
15791 pts/1 00:00:00 sh
15792 pts/1 00:00:00 ps
15793 pts/1 00:00:00 sleep
[1] - Done (sleep 2)
$ OK
[2] + Done (sleep 2; echo OK)
$ { sleep 2; echo OK; } & ps
PID TTY TIME CMD
15071 pts/1 00:00:00 bash
15305 pts/1 00:00:00 sh
15809 pts/1 00:00:00 sh
15810 pts/1 00:00:00 ps
15811 pts/1 00:00:00 sleep
$ OK
[1] + Done sleep 2; echo OK
Also try these variants:
( ( sleep 2; echo OK ) ) & ps
( ( sleep 2; echo OK ) & ) & ps
{ { sleep 2; echo OK;} ;} & ps
{ { sleep 2; echo OK;} & } & ps
They all start the same number of processes.
Related:
https://unix.stackexchange.com/questions/127334/bash-subshell-creation-with-curly-braces
https://unix.stackexchange.com/questions/267660/difference-between-parentheses-and-braces-in-terminal/267661
So let's think about this a bit.
from bunsen-configs.
The first article uses examples with pipes; those create subshells alright.
But that's not what I'm talking about.
The accepted answer from the second article seems to confirm what I'm saying, but also what you're saying - maybe this statement:
Parentheses cause the commands to be run in a subshell.
Braces cause the commands to be grouped together but not in a subshell.
is to be seen in terms of shell functionality only, and not resource usage.
I didn't consider Debian's /bin/sh is linked to dash (something I also did now btw), which certainly makes a difference performance-wise, but the logic should be the same... again, as you observed.
I still believe curly braces would set a better example for aspiring hackers, but one should have something to back that up with. Still researching...
from bunsen-configs.
maybe this statement:
Parentheses cause the commands to be run in a subshell.
Braces cause the commands to be grouped together but not in a subshell.is to be seen in terms of shell functionality only, and not resource usage.
That's how it looks to me - a saving in child processes looks hard to achieve, but there is a difference in things like variable scope when running in a subshell. That difference might be desirable, or not, depending on the particular case.
Of course, in the case of a simple process launch, needing no sleep, there is no question of wanting a subshell command &
so indeed it seems reasonable to ask why we should need one when adding a delay, except that that has become the norm.
And, in the second article:
if you are interested in specific aspects, be careful and check your shell for its actual behavior
Switching from bash to dash can bring a substantial speed gain if the extra bash features can be lived without. I always try to use #!/bin/sh for system scripts, for portability. There are sometimes subtle catches though.
I still believe curly braces would set a better example for aspiring hackers, but one should have something to back that up with.
autostart is a user-editable file, so that's a valid point. Such files should be:
*) easy to read and understand, and
*) provide a good template for copying.
But as you say, we ought to have something substantial to point to before making such an unconventional (compared with what others are using) change.
from bunsen-configs.
Lacking any more evidence that switching to { } would bring any tangible benefits, let's stay with the conventional ( ) for now.
from bunsen-configs.
Related Issues (20)
- Super+w doesn't work on BL-Lithium ARM install... HOT 1
- Lithium bl-xdg-autostart script args faulty error trapping HOT 6
- Hyperlinks (e.g. in PDFs) open in non-default browser HOT 10
- i want to ask HOT 2
- Change directory HOT 1
- Tint2 gitlab has new adress HOT 2
- add menu for hw-probe HOT 2
- Jgmenu systemreport shows too little information HOT 2
- [Suggestion] Thunar keybind / F4 to Open terminal here HOT 3
- prepend.csv: Illegal quoting in line 6 HOT 3
- installing .deb programs bugging my mousepad HOT 3
- ALT key is (maybe) being eaten by the desktop HOT 4
- bl-user-setup doesn't work with domain join users HOT 4
- skel/.config/blob/: tint2 config file names do not match those in skel/.config/tint2 HOT 1
- lightdm: Set greeter-hide-users=false to show available users in greeter HOT 5
- Update bl-mpv for mpv=0.23 and provide skel/.config/mpv/mpv.conf HOT 2
- mpv config: window is forced even when running mpv in terminal HOT 6
- mpv config: BL uses the deprecated [pseudo-gui] profile HOT 2
- /grub2/i386-pc/normal.mod not Found when Booting HELIUM5 AMD64 Installation from an USB-drive HOT 2
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 bunsen-configs.