How to get a shell session with the fewest number of defined variables (consistent with functioning at a...

Board Chinese train at a different station (on-route)

Could a complex system of reaction wheels be used to propel a spacecraft?

Fixing a blind bolt hole when the first 2-3 threads are ruined?

Group by consecutive index numbers

Is the Amazon rainforest the "world's lungs"?

Why doesn't Starship have four landing legs?

Why did the population of Bhutan drop by 70% between 2007 and 2008?

What does "-1" represent in the value range for unsigned int and signed int?

Why is "I let him to sleep" incorrect (or is it)?

is "prohibition against," a double negative?

What's the difference between a variable and a memory location?

How do I portray irrational anger in first person?

Get contents before a colon

Are sweatpants frowned upon on flights?

Idiomatic way to create an immutable and efficient class in C++?

Why didn't Doc believe Marty was from the future?

Moscow SVO airport, how to avoid scam taxis without pre-booking?

Wrong Stamping of UK Visa

What is Soda Fountain Etiquette?

Under GDPR, can I give permission once to allow everyone to store and process my data?

What control character is ^ in the buffer in a file open in vim?

Heat output from a 200W electric radiator?

Count the number of triangles

Why did Starhopper's exhaust plume become brighter just before landing?



How to get a shell session with the fewest number of defined variables (consistent with functioning at a all)


How to print only defined variables (shell and/or environment variables) in bashIn zsh how can I list all the environment variables?modify user-defined System Variables(that is a number) of remote Server machine using ssh?How can I list all shell variables?How to prevent the caller's shell from being used in sudoGet environment variables of running sessionArrays in Zsh. Check if any of the following variables is not definedAre the environment variables defined by POSIX for a shell, or for any process which doesn't necessarily run shell?






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







0















I am aware of



/usr/bin/env -i /bin/bash --login --norc --noprofile


And indeed, If I run the above, and immediately after run printenv in the new shell session, I see that very few exported variables are defined:



% /usr/bin/env -i /bin/bash --login --norc --noprofile
bash-4.4$ printenv | /usr/bin/perl -lpe 's/=.*//'
PWD
SHLVL
_
bash-4.4$


But if instead I run set, I see a lot of variables:



bash-4.4$ set | /usr/bin/perl -lpe 's/=.*//'
BASH
BASHOPTS
BASH_ALIASES
BASH_ARGC
BASH_ARGV
BASH_CMDS
BASH_LINENO
BASH_SOURCE
BASH_VERSINFO
BASH_VERSION
COLUMNS
DIRSTACK
EUID
GROUPS
HISTFILE
HISTFILESIZE
HISTSIZE
HOSTNAME
HOSTTYPE
IFS
LINES
MACHTYPE
MAILCHECK
OPTERR
OPTIND
OSTYPE
PATH
PPID
PS1
PS2
PS4
PWD
SHELL
SHELLOPTS
SHLVL
TERM
UID
_
bash-4.4$


For the sake of this question, let me define a shell variable as being "indispensable" iff bash simply won't run unless this variable is present (as indicated by its showing up in set's output). For example, PPID appears to be indispensable. (bash emits an error if one tries to unset it.)



What is the easiest way to reduce the set of defined variables to hold only the indispensable ones?










share|improve this question



























  • Your question is too broad and would be impossible for anyone to completely answer because it depends entirely on what you plan to do with the system. The bare functional minimum is going to determine that and we have no idea of what that is for you or if it's going to change under certain circumstances.

    – Nasir Riley
    1 hour ago











  • Do you understand the difference between shell variables and environment variables? If so, why is your question title "how to get the barest possible environment" when you're asking for shell variables that aren't environment variables to be removed?

    – Joseph Sible
    1 hour ago




















0















I am aware of



/usr/bin/env -i /bin/bash --login --norc --noprofile


And indeed, If I run the above, and immediately after run printenv in the new shell session, I see that very few exported variables are defined:



% /usr/bin/env -i /bin/bash --login --norc --noprofile
bash-4.4$ printenv | /usr/bin/perl -lpe 's/=.*//'
PWD
SHLVL
_
bash-4.4$


But if instead I run set, I see a lot of variables:



bash-4.4$ set | /usr/bin/perl -lpe 's/=.*//'
BASH
BASHOPTS
BASH_ALIASES
BASH_ARGC
BASH_ARGV
BASH_CMDS
BASH_LINENO
BASH_SOURCE
BASH_VERSINFO
BASH_VERSION
COLUMNS
DIRSTACK
EUID
GROUPS
HISTFILE
HISTFILESIZE
HISTSIZE
HOSTNAME
HOSTTYPE
IFS
LINES
MACHTYPE
MAILCHECK
OPTERR
OPTIND
OSTYPE
PATH
PPID
PS1
PS2
PS4
PWD
SHELL
SHELLOPTS
SHLVL
TERM
UID
_
bash-4.4$


For the sake of this question, let me define a shell variable as being "indispensable" iff bash simply won't run unless this variable is present (as indicated by its showing up in set's output). For example, PPID appears to be indispensable. (bash emits an error if one tries to unset it.)



What is the easiest way to reduce the set of defined variables to hold only the indispensable ones?










share|improve this question



























  • Your question is too broad and would be impossible for anyone to completely answer because it depends entirely on what you plan to do with the system. The bare functional minimum is going to determine that and we have no idea of what that is for you or if it's going to change under certain circumstances.

    – Nasir Riley
    1 hour ago











  • Do you understand the difference between shell variables and environment variables? If so, why is your question title "how to get the barest possible environment" when you're asking for shell variables that aren't environment variables to be removed?

    – Joseph Sible
    1 hour ago
















0












0








0








I am aware of



/usr/bin/env -i /bin/bash --login --norc --noprofile


And indeed, If I run the above, and immediately after run printenv in the new shell session, I see that very few exported variables are defined:



% /usr/bin/env -i /bin/bash --login --norc --noprofile
bash-4.4$ printenv | /usr/bin/perl -lpe 's/=.*//'
PWD
SHLVL
_
bash-4.4$


But if instead I run set, I see a lot of variables:



bash-4.4$ set | /usr/bin/perl -lpe 's/=.*//'
BASH
BASHOPTS
BASH_ALIASES
BASH_ARGC
BASH_ARGV
BASH_CMDS
BASH_LINENO
BASH_SOURCE
BASH_VERSINFO
BASH_VERSION
COLUMNS
DIRSTACK
EUID
GROUPS
HISTFILE
HISTFILESIZE
HISTSIZE
HOSTNAME
HOSTTYPE
IFS
LINES
MACHTYPE
MAILCHECK
OPTERR
OPTIND
OSTYPE
PATH
PPID
PS1
PS2
PS4
PWD
SHELL
SHELLOPTS
SHLVL
TERM
UID
_
bash-4.4$


For the sake of this question, let me define a shell variable as being "indispensable" iff bash simply won't run unless this variable is present (as indicated by its showing up in set's output). For example, PPID appears to be indispensable. (bash emits an error if one tries to unset it.)



What is the easiest way to reduce the set of defined variables to hold only the indispensable ones?










share|improve this question
















I am aware of



/usr/bin/env -i /bin/bash --login --norc --noprofile


And indeed, If I run the above, and immediately after run printenv in the new shell session, I see that very few exported variables are defined:



% /usr/bin/env -i /bin/bash --login --norc --noprofile
bash-4.4$ printenv | /usr/bin/perl -lpe 's/=.*//'
PWD
SHLVL
_
bash-4.4$


But if instead I run set, I see a lot of variables:



bash-4.4$ set | /usr/bin/perl -lpe 's/=.*//'
BASH
BASHOPTS
BASH_ALIASES
BASH_ARGC
BASH_ARGV
BASH_CMDS
BASH_LINENO
BASH_SOURCE
BASH_VERSINFO
BASH_VERSION
COLUMNS
DIRSTACK
EUID
GROUPS
HISTFILE
HISTFILESIZE
HISTSIZE
HOSTNAME
HOSTTYPE
IFS
LINES
MACHTYPE
MAILCHECK
OPTERR
OPTIND
OSTYPE
PATH
PPID
PS1
PS2
PS4
PWD
SHELL
SHELLOPTS
SHLVL
TERM
UID
_
bash-4.4$


For the sake of this question, let me define a shell variable as being "indispensable" iff bash simply won't run unless this variable is present (as indicated by its showing up in set's output). For example, PPID appears to be indispensable. (bash emits an error if one tries to unset it.)



What is the easiest way to reduce the set of defined variables to hold only the indispensable ones?







shell environment-variables






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 34 mins ago







kjo

















asked 1 hour ago









kjokjo

4,52113 gold badges41 silver badges73 bronze badges




4,52113 gold badges41 silver badges73 bronze badges
















  • Your question is too broad and would be impossible for anyone to completely answer because it depends entirely on what you plan to do with the system. The bare functional minimum is going to determine that and we have no idea of what that is for you or if it's going to change under certain circumstances.

    – Nasir Riley
    1 hour ago











  • Do you understand the difference between shell variables and environment variables? If so, why is your question title "how to get the barest possible environment" when you're asking for shell variables that aren't environment variables to be removed?

    – Joseph Sible
    1 hour ago





















  • Your question is too broad and would be impossible for anyone to completely answer because it depends entirely on what you plan to do with the system. The bare functional minimum is going to determine that and we have no idea of what that is for you or if it's going to change under certain circumstances.

    – Nasir Riley
    1 hour ago











  • Do you understand the difference between shell variables and environment variables? If so, why is your question title "how to get the barest possible environment" when you're asking for shell variables that aren't environment variables to be removed?

    – Joseph Sible
    1 hour ago



















Your question is too broad and would be impossible for anyone to completely answer because it depends entirely on what you plan to do with the system. The bare functional minimum is going to determine that and we have no idea of what that is for you or if it's going to change under certain circumstances.

– Nasir Riley
1 hour ago





Your question is too broad and would be impossible for anyone to completely answer because it depends entirely on what you plan to do with the system. The bare functional minimum is going to determine that and we have no idea of what that is for you or if it's going to change under certain circumstances.

– Nasir Riley
1 hour ago













Do you understand the difference between shell variables and environment variables? If so, why is your question title "how to get the barest possible environment" when you're asking for shell variables that aren't environment variables to be removed?

– Joseph Sible
1 hour ago







Do you understand the difference between shell variables and environment variables? If so, why is your question title "how to get the barest possible environment" when you're asking for shell variables that aren't environment variables to be removed?

– Joseph Sible
1 hour ago












0






active

oldest

votes














Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
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: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
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%2funix.stackexchange.com%2fquestions%2f538166%2fhow-to-get-a-shell-session-with-the-fewest-number-of-defined-variables-consiste%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Unix & Linux Stack Exchange!


  • 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%2funix.stackexchange.com%2fquestions%2f538166%2fhow-to-get-a-shell-session-with-the-fewest-number-of-defined-variables-consiste%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

Taj Mahal Inhaltsverzeichnis Aufbau | Geschichte | 350-Jahr-Feier | Heutige Bedeutung | Siehe auch |...

Baia Sprie Cuprins Etimologie | Istorie | Demografie | Politică și administrație | Arii naturale...

Nicolae Petrescu-Găină Cuprins Biografie | Opera | In memoriam | Varia | Controverse, incertitudini...