इस पर विचार करो:
$ ssh localhost bash -c 'export foo=bar'
terdon@localhost's password:
declare -x DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/1000/bus"
declare -x HOME="/home/terdon"
declare -x LOGNAME="terdon"
declare -x MAIL="/var/spool/mail/terdon"
declare -x OLDPWD
declare -x PATH="/usr/bin:/bin:/usr/sbin:/sbin"
declare -x PWD="/home/terdon"
declare -x SHELL="/bin/bash"
declare -x SHLVL="2"
declare -x SSH_CLIENT="::1 55858 22"
declare -x SSH_CONNECTION="::1 55858 ::1 22"
declare -x USER="terdon"
declare -x XDG_RUNTIME_DIR="/run/user/1000"
declare -x XDG_SESSION_ID="c5"
declare -x _="/usr/bin/bash"
कमांड bash -cकी उस सूची में ssh परिणाम के माध्यम से चलने वाले सत्र के भीतर एक चर का निर्यात क्यों करता है declare -x(वर्तमान में निर्यात की गई चर की सूची, जहां तक मैं बता सकता हूं)?
के बिना एक ही बात चल रहा bash -cहै कि:
$ ssh localhost 'export foo=bar'
terdon@localhost's password:
$
और न ही ऐसा होता है यदि हम नहीं करते हैं export:
$ ssh localhost bash -c 'foo=bar'
terdon@localhost's password:
$
मैंने इसे एक उबंटू मशीन से दूसरे (दोनों बैश 4.3.11 रनिंग) पर और एक आर्क मशीन पर दिखाया, जैसा कि ऊपर दिखाया गया है (bash संस्करण 4.4.5)।
यहाँ क्या चल रहा है? bash -cकॉल के अंदर एक चर निर्यात करने से यह उत्पादन क्यों होता है?
exportसमझने की कोशिश कर रहा हूँ कि क्या हो रहा है। मैं यह स्पष्ट करने के लिए संपादन करूंगा कि यह केवल निर्यात करते समय होता है।
exportअकेले चलाने का उत्पादन है ? यह मैं नहीं समझ पाया था।
foo=barसूची में दिखाई नहीं देता है।
export। Zsh ही काम करता है।