Skip to main content
added 253 characters in body
Source Link
Stéphane Chazelas
  • 586.8k
  • 96
  • 1.1k
  • 1.7k
  • dash versions 0.3.8-15 to 0.5.10.2 (see change).
  • the sh of NetBSD (also based on the Almquist shell).
  • The sh of FreeBSD 9.2 or older (see the change in 9.3)
  • yash
  • zsh with versions prior to 5.1 in ksh or sh emulation (or for export var="$(cmd)" where zsh would perform word splitting otherwise (not globbing)).
  • bash
  • ksh (all implementations)
  • the sh of FreeBSD 9.3 or newer
  • busybox' ash-based sh (since 2005)
  • zsh
  • dash 0.5.11 or newer.

If the export/local command name itself is quoted (even in part like "export" a="$b", 'ex'port a="$b", \export a="$b", or even ""export a="$b"), the quotes around $b are needed except in AT&T ksh and, mksh and recent versions of dash.

If export/local or some part of it is the result of some expansion (like in cmd=export; "$cmd" a="$b" or even export$(:) a="$b") or in things like dryrun=; $dryrun export a="$b"), then the quotes are needed except in every shellrecent versions of dash.

For command export a="$b", the quotes are needed in every shell but mksh, ksh93, recent dash, and bash -o posix (with the same caveats about command and export not being the result of some expansion in shells other than dash).

  • dash
  • the sh of NetBSD (also based on the Almquist shell).
  • The sh of FreeBSD 9.2 or older (see the change in 9.3)
  • yash
  • zsh with versions prior to 5.1 in ksh or sh emulation (or for export var="$(cmd)" where zsh would perform word splitting otherwise (not globbing)).
  • bash
  • ksh (all implementations)
  • the sh of FreeBSD 9.3 or newer
  • busybox' ash-based sh (since 2005)
  • zsh

If the export/local command name itself is quoted (even in part like "export" a="$b", 'ex'port a="$b", \export a="$b", or even ""export a="$b"), the quotes around $b are needed except in AT&T ksh and mksh.

If export/local or some part of it is the result of some expansion (like in cmd=export; "$cmd" a="$b" or even export$(:) a="$b") or in things like dryrun=; $dryrun export a="$b"), then the quotes are needed in every shell.

For command export a="$b", the quotes are needed in every shell but mksh, ksh93 and bash -o posix (with the same caveats about command and export not being the result of some expansion).

  • dash versions 0.3.8-15 to 0.5.10.2 (see change).
  • the sh of NetBSD (also based on the Almquist shell).
  • The sh of FreeBSD 9.2 or older (see the change in 9.3)
  • yash
  • zsh with versions prior to 5.1 in ksh or sh emulation (or for export var="$(cmd)" where zsh would perform word splitting otherwise (not globbing)).
  • bash
  • ksh (all implementations)
  • the sh of FreeBSD 9.3 or newer
  • busybox' ash-based sh (since 2005)
  • zsh
  • dash 0.5.11 or newer.

If the export/local command name itself is quoted (even in part like "export" a="$b", 'ex'port a="$b", \export a="$b", or even ""export a="$b"), the quotes around $b are needed except in AT&T ksh, mksh and recent versions of dash.

If export/local or some part of it is the result of some expansion (like in cmd=export; "$cmd" a="$b" or even export$(:) a="$b") or in things like dryrun=; $dryrun export a="$b"), then the quotes are needed except in recent versions of dash.

For command export a="$b", the quotes are needed in every shell but mksh, ksh93, recent dash, and bash -o posix (with the same caveats about command and export not being the result of some expansion in shells other than dash).

added 17 characters in body
Source Link
Stéphane Chazelas
  • 586.8k
  • 96
  • 1.1k
  • 1.7k

For command export a="$b", the quotes are needed in every shell but mksh and, ksh93 and bash -o posix (with the same caveats about command and export not being the result of some expansion).

For command export a="$b", the quotes are needed in every shell but mksh and ksh93 (with the same caveats about command and export not being the result of some expansion).

For command export a="$b", the quotes are needed in every shell but mksh, ksh93 and bash -o posix (with the same caveats about command and export not being the result of some expansion).

typo
Source Link
terdon
  • 252.7k
  • 69
  • 481
  • 719

My adviseadvice would be to always quote.

My advise would be to always quote.

My advice would be to always quote.

added 322 characters in body
Source Link
Stéphane Chazelas
  • 586.8k
  • 96
  • 1.1k
  • 1.7k
Loading
deleted 107 characters in body
Source Link
Stéphane Chazelas
  • 586.8k
  • 96
  • 1.1k
  • 1.7k
Loading
added 9 characters in body
Source Link
Stéphane Chazelas
  • 586.8k
  • 96
  • 1.1k
  • 1.7k
Loading
added 9 characters in body
Source Link
Stéphane Chazelas
  • 586.8k
  • 96
  • 1.1k
  • 1.7k
Loading
added 133 characters in body
Source Link
Stéphane Chazelas
  • 586.8k
  • 96
  • 1.1k
  • 1.7k
Loading
added 9 characters in body; added 66 characters in body
Source Link
Stéphane Chazelas
  • 586.8k
  • 96
  • 1.1k
  • 1.7k
Loading
added 77 characters in body
Source Link
Stéphane Chazelas
  • 586.8k
  • 96
  • 1.1k
  • 1.7k
Loading
added 175 characters in body
Source Link
Stéphane Chazelas
  • 586.8k
  • 96
  • 1.1k
  • 1.7k
Loading
added 59 characters in body
Source Link
Stéphane Chazelas
  • 586.8k
  • 96
  • 1.1k
  • 1.7k
Loading
mention FreeBSD
Source Link
Stéphane Chazelas
  • 586.8k
  • 96
  • 1.1k
  • 1.7k
Loading
added 22 characters in body
Source Link
Stéphane Chazelas
  • 586.8k
  • 96
  • 1.1k
  • 1.7k
Loading
more nonsense with export special treatment
Source Link
Stéphane Chazelas
  • 586.8k
  • 96
  • 1.1k
  • 1.7k
Loading
added 369 characters in body
Source Link
Stéphane Chazelas
  • 586.8k
  • 96
  • 1.1k
  • 1.7k
Loading
added 15 characters in body
Source Link
Stéphane Chazelas
  • 586.8k
  • 96
  • 1.1k
  • 1.7k
Loading
zsh now parses typeset and co like assignments like bash/ksh.
Source Link
Stéphane Chazelas
  • 586.8k
  • 96
  • 1.1k
  • 1.7k
Loading
disambiguate `yash` as it seems there are several shells by that name.
Source Link
Stéphane Chazelas
  • 586.8k
  • 96
  • 1.1k
  • 1.7k
Loading
added 94 characters in body
Source Link
Stéphane Chazelas
  • 586.8k
  • 96
  • 1.1k
  • 1.7k
Loading
added 293 characters in body
Source Link
Stéphane Chazelas
  • 586.8k
  • 96
  • 1.1k
  • 1.7k
Loading
Source Link
Stéphane Chazelas
  • 586.8k
  • 96
  • 1.1k
  • 1.7k
Loading