Skip to content

Magenaut

  • Home
  • Topics
    • Notes
    • Tutorial
    • Bug fixing
    • Extension
    • Server
  • Q&A
  • Privacy Policy
  • About

subshell

Stateful bash function

August 11, 2022 by Magenaut

I’d like to implement a function in Bash which increases (and returns) a count with every call. Unfortunately this seems non-trivial since I’m invoking the function inside a subshell and it consequently cannot modify its parent shell’s variables.

Categories Q&A, Unix & Linux Tags bash, function, prompt, shell-script, subshell Leave a comment

How to make a variable from a subshell available in the parent shell

August 10, 2022 by Magenaut

I’ve written a quick-and-dirty script to time some reports from a web service:

Categories Q&A, Unix & Linux Tags bash, io-redirection, shell, subshell Leave a comment

How can I get the pid of a subshell?

August 10, 2022 by Magenaut

How can I get the pid of a subshell?

Categories Q&A, Unix & Linux Tags bash, process, subshell Leave a comment

Why is a variable visible in a subshell?

August 10, 2022 by Magenaut

The Learning Bash Book mentions that a subshell will inherit only environment variables and file descriptors, etc., and that it will not inherit variables that are not exported:

Categories Q&A, Unix & Linux Tags bash, shell, subshell Leave a comment

Background process of subshell strange behaviour

August 10, 2022 by Magenaut

I wonder why some similar bash commands behave the way they do.

Categories Q&A, Unix & Linux Tags background-process, bash, subshell Leave a comment

$BASHPID And $$ differ in some cases

August 10, 2022 by Magenaut

I’m reading “BASH pocket guide of Oreilly”.
It said:

Categories Q&A, Unix & Linux Tags bash, parameter, process, shell, subshell Leave a comment

Rule for invoking subshell in Bash?

August 9, 2022 by Magenaut

I seem to misunderstand the Bash rule for creating a subshell. I thought parentheses always creates a subshell, which runs as its own process.

Categories Q&A, Unix & Linux Tags bash, shell, shell-script, subshell Leave a comment

How can I detect if I’m in a subshell?

August 9, 2022 by Magenaut

I’m trying to write a function to replace the functionality of the exit builtin to prevent myself from exiting the terminal.

Categories Q&A, Unix & Linux Tags bash, exit, shell, subshell Leave a comment

Why does a brace command group need spaces after the opening brace in POSIX Shell Grammar?

August 8, 2022 by Magenaut

TL;DR: Why does POSIX brace group need spaces after { reserved word but subshell doesn’t after reserved word (?

Categories Q&A, Unix & Linux Tags posix, shell, subshell, syntax Leave a comment

Why (…) doesn’t spawn a new child process when run in background?

August 8, 2022 by Magenaut

After running the command

Categories Q&A, Unix & Linux Tags bash, command, subshell Leave a comment
Older posts
Page1 Page2 Next →
  1. michealSmith07 on Is there a way to dynamically refresh the less command?August 21, 2022

    That is a very nice post. I like this post.

  2. anonymous on Fix libwacom9 dependency issue when upgrade DebianJune 27, 2022

    saved my day!! Thanks for the help…

  3. sreedhar on Fix libwacom9 dependency issue when upgrade DebianMay 10, 2022

    Thanks its working

  4. saintnick on Fix libwacom9 dependency issue when upgrade DebianMay 10, 2022

    remove libwacom2 worked for me as well

  5. ranafoul on Fix libwacom9 dependency issue when upgrade DebianApril 22, 2022

    apt remove libwacom2 helped on kali 2022.01. gr8

.net ajax asp.net asp.net-core asp.net-mvc asp.net-mvc-3 asp.net-mvc-4 asp.net-web-api bash c# command-line css custom-post-types custom-taxonomy dataframe dictionary django entity-framework functions gridview html iis javascript jquery json linux list matplotlib numpy pandas php plugin-development plugins posts python python-2.7 python-3.x security shell shell-script sql string vb.net webforms wp-query

© 2026 Magenaut • Built with GeneratePress