Skip to main content
additionally add - did i write that?
Source Link
mikeserv
  • 59.4k
  • 10
  • 122
  • 242

You can also call set without any arguments to add a list of all of the shell's currently set variables - also quoted for reentry to the shell. And you can - in bash - additionally add the command typeset -fp to also include all currently declared shell functions. You can lump it all together and eval when ready. You can even call alias without arguments for more of the same. That... might cover it, though. I guess there is "$@" - which you'd have to put in a bash array first, I suppose, before doing set.

You can also call set without any arguments to add a list of all of the shell's currently set variables - also quoted for reentry to the shell. And you can - in bash - additionally add the command typeset -fp to also include all currently declared shell functions. You can lump it all together and eval when ready. You can even call alias without arguments for more of the same. That... might cover it, though. I guess there is "$@" - which you'd have to put in a bash array first, I suppose, before doing set.

You can also call set without any arguments to add a list of all of the shell's currently set variables - also quoted for reentry to the shell. And you can - in bash - add the command typeset -fp to also include all currently declared shell functions. You can lump it all together and eval when ready. You can even call alias without arguments for more of the same. That... might cover it, though. I guess there is "$@" - which you'd have to put in a bash array first, I suppose, before doing set.

incorporate nkatsar's comment to fix shopt command, plus some noise to get 6 total characters difference
Source Link
thanasisp
  • 8.5k
  • 2
  • 29
  • 40
state=$(set +o; shopt -p) 
#do what you want with options here including shopt
eval "$state"
state=$(set +o; shopt -p) 
#do what you want with options here including shopt
eval "$state"
state=$(set +o; shopt -p) 
#do what you want with options here
eval "$state"
incorporate nkatsar's comment to fix shopt command, plus some noise to get 6 total characters difference
Source Link
state=$(set +o;shopt+o; shopt -p) 
#do what you want with options here including shopt
eval "$state"
state=$(set +o;shopt)
#do what you want with options here
eval "$state"
state=$(set +o; shopt -p) 
#do what you want with options here including shopt
eval "$state"
replaced http://unix.stackexchange.com/ with https://unix.stackexchange.com/
Source Link
Loading
deleted 6 characters in body
Source Link
mikeserv
  • 59.4k
  • 10
  • 122
  • 242
Loading
added 984 characters in body
Source Link
mikeserv
  • 59.4k
  • 10
  • 122
  • 242
Loading
added 463 characters in body
Source Link
mikeserv
  • 59.4k
  • 10
  • 122
  • 242
Loading
added 621 characters in body
Source Link
mikeserv
  • 59.4k
  • 10
  • 122
  • 242
Loading
Source Link
mikeserv
  • 59.4k
  • 10
  • 122
  • 242
Loading