簡體   English   中英

Bash-命令和變量擴展

[英]Bash - Command and variable expansion

閱讀POSIX Shell手冊Bash手冊后,我仍然無法解釋以下行為:

% bash --version
GNU bash, version 3.2.48(1)-release (x86_64-unknown-linux-gnu)
Copyright (C) 2007 Free Software Foundation, Inc.
% bash
% A=1 B=$A bash -c 'echo $B'
1
% A=1 B=$A bash -c 'echo $B'

%

其他外殼程序(如zsh或ksh)正在執行我期望的操作,即始終顯示為“ 1”。 因此,它似乎特定於Bash。

有人可以解釋這種行為嗎?如果可能,請指向文檔中解釋的地方?

提前致謝!

此行為似乎特定於Bash 3.2,並且該片段按預期在更高版本的4.2上運行。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM