سؤال

For the obvious reason I do not want to export COLUMNS in my normal bash shell.

However for the purpose of one particular subshell, I need access to the value of COLUMNS of its parent. In other words, in a regular bash shell, I want to call a shell script that uses ls -Cw $COLUMNS, with the value of $COLUMNS from its parent.

Is there any way to access a parent's environment variables other than them being exported by the parent?

هل كانت مفيدة؟

المحلول

You can't. But there are ways to get the number of columns other than environment variables. For example

COLUMNS=$(tput cols)
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top