Skip to main content
added 51 characters in body
Source Link
Stéphane Chazelas
  • 584.9k
  • 96
  • 1.1k
  • 1.7k

Yes, doing filename expansion upon command substitution and other expansions is generally not wanted¹ and not done by default in zsh except in sh/ksh emulation (globsubst option).

While you could use ${~$(...)} to request the use of globsusbt for that particular command substitution (and by the way, you don't need the paste part, both space and newline are in the default value of $IFS), a much better way to do it with zsh would be:

ids=($(qstat))
tail -F logs/*${^ids}

Note that if any of those globs fail to match any file, the command will be aborted.

tail -F logs/*${^ids}(N)

(where (N) activates nullglob for those globs) would avoid that but would run tail -F without argument if there was no file at all (see Why is nullglob not default?).

You could also make it:

logs=(logs/*${^$(qstat)}(N))
(($#logs)) && tail -F $logs

¹ The fact that bash and other Bourne-like shells do it could be seen as a bug. That's one reason why you need to quote all your variablesyou need to quote all your variables there, or why you need set -o noglob before running using an unquoted $(...) when you only want the splitting part of that split+glob. All more modern shells that don't carry the Bourne shell baggage like rc, es or fish don't do it either.

Yes, doing filename expansion upon command substitution and other expansions is generally not wanted¹ and not done by default in zsh except in sh/ksh emulation (globsubst option).

While you could use ${~$(...)} to request the use of globsusbt for that particular command substitution (and by the way, you don't need the paste part, both space and newline are in the default value of $IFS), a much better way to do it with zsh would be:

ids=($(qstat))
tail -F logs/*${^ids}

Note that if any of those globs fail to match any file, the command will be aborted.

tail -F logs/*${^ids}(N)

would avoid that but would run tail -F without argument if there was no file at all.

You could also make it:

logs=(logs/*${^$(qstat)}(N))
(($#logs)) && tail -F $logs

¹ The fact that bash and other Bourne-like shells do it could be seen as a bug. That's one reason why you need to quote all your variables there, or why you need set -o noglob before running using an unquoted $(...) when you only want the splitting part of that split+glob. All more modern shells that don't carry the Bourne shell baggage like rc, es or fish don't do it either.

Yes, doing filename expansion upon command substitution and other expansions is generally not wanted¹ and not done by default in zsh except in sh/ksh emulation (globsubst option).

While you could use ${~$(...)} to request the use of globsusbt for that particular command substitution (and by the way, you don't need the paste part, both space and newline are in the default value of $IFS), a much better way to do it with zsh would be:

ids=($(qstat))
tail -F logs/*${^ids}

Note that if any of those globs fail to match any file, the command will be aborted.

tail -F logs/*${^ids}(N)

(where (N) activates nullglob for those globs) would avoid that but would run tail -F without argument if there was no file at all (see Why is nullglob not default?).

You could also make it:

logs=(logs/*${^$(qstat)}(N))
(($#logs)) && tail -F $logs

¹ The fact that bash and other Bourne-like shells do it could be seen as a bug. That's one reason why you need to quote all your variables there, or why you need set -o noglob before using an unquoted $(...) when you only want the splitting part of that split+glob. All more modern shells that don't carry the Bourne shell baggage like rc, es or fish don't do it either.

added 301 characters in body
Source Link
Stéphane Chazelas
  • 584.9k
  • 96
  • 1.1k
  • 1.7k

Yes, doing filename expansion upon command substitution and other expansions is generally not wanted¹ and not done by default in zsh except in sh/ksh emulation (globsubst option).

While you could use ${~$(...)} to request the use of globsusbt for that particular command substitution (and by the way, you don't need the paste part, both space and newline are in the default value of $IFS), a much better way to do it with zsh would be:

ids=($(qstat))
tail -F logs/*${^ids}

Note that if any of those globs fail to match any file, the command will be aborted.

tail -F logs/*${^ids}(N)

would avoid that but would run tail -F without argument if there was no file at all.

You could also make it:

logs=(logs/*${^$(qstat)}(N))
(($#logs)) && tail -F $logs

¹ The fact that bash and other Bourne-like shells do it could be seen as a bug. That's one reason why you need to quote all your variables there, or why you need set -o noglob before running using an unquoted $(...) when you only want the splitting part of that split+glob. All more modern shells that don't carry the Bourne shell baggage like rc, es or fish don't do it either.

Yes, doing filename expansion upon command substitution and other expansions is generally not wanted¹ and not done by default in zsh except in sh/ksh emulation (globsubst option).

While you could use ${~$(...)} to request the use of globsusbt for that particular command substitution, a much better way to do it with zsh would be:

ids=($(qstat))
tail -F logs/*${^ids}

Note that if any of those globs fail to match any file, the command will be aborted.

tail -F logs/*${^ids}(N)

would avoid that but would run tail -F without argument if there was no file at all.

You could also make it:

logs=(logs/*${^$(qstat)}(N))
(($#logs)) && tail -F $logs

¹ The fact that bash and other Bourne-like shells do it could be seen as a bug. That's one reason why you need to quote all your variables there, or why you need set -o noglob before running using an unquoted $(...) when you only want the splitting part of that split+glob. All more modern shells that don't carry the Bourne shell baggage like rc, es or fish don't do it either.

Yes, doing filename expansion upon command substitution and other expansions is generally not wanted¹ and not done by default in zsh except in sh/ksh emulation (globsubst option).

While you could use ${~$(...)} to request the use of globsusbt for that particular command substitution (and by the way, you don't need the paste part, both space and newline are in the default value of $IFS), a much better way to do it with zsh would be:

ids=($(qstat))
tail -F logs/*${^ids}

Note that if any of those globs fail to match any file, the command will be aborted.

tail -F logs/*${^ids}(N)

would avoid that but would run tail -F without argument if there was no file at all.

You could also make it:

logs=(logs/*${^$(qstat)}(N))
(($#logs)) && tail -F $logs

¹ The fact that bash and other Bourne-like shells do it could be seen as a bug. That's one reason why you need to quote all your variables there, or why you need set -o noglob before running using an unquoted $(...) when you only want the splitting part of that split+glob. All more modern shells that don't carry the Bourne shell baggage like rc, es or fish don't do it either.

added 301 characters in body
Source Link
Stéphane Chazelas
  • 584.9k
  • 96
  • 1.1k
  • 1.7k

Yes, doing filename expansion upon command substitution and other expansions is generally not wantedwanted¹ and not done by default in zsh except in sh/ksh emulation (globsubst option).

While you could use ${~$(...)} to request the use of globsusbt for that particular command substitution, a much better way to do it with zsh would be:

ids=($(qstat))
tail -F logs/*${^ids}

Note that if any of those globs fail to match any file, the command will be aborted.

tail -F logs/*${^ids}(N)

would avoid that but would run tail -F without argument if there was no file at all.

You could also make it:

logs=(logs/*${^$(qstat)}(N))
(($#logs)) && tail -F $logs

¹ The fact that bash and other Bourne-like shells do it could be seen as a bug. That's one reason why you need to quote all your variables there, or why you need set -o noglob before running using an unquoted $(...) when you only want the splitting part of that split+glob. All more modern shells that don't carry the Bourne shell baggage like rc, es or fish don't do it either.

Yes, doing filename expansion upon command substitution and other expansions is generally not wanted and not done by default in zsh except in sh/ksh emulation (globsubst option).

While you could use ${~$(...)} to request the use of globsusbt for that particular command substitution, a much better way to do it with zsh would be:

ids=($(qstat))
tail -F logs/*${^ids}

Note that if any of those globs fail to match any file, the command will be aborted.

tail -F logs/*${^ids}(N)

would avoid that but would run tail -F without argument if there was no file at all.

You could also make it:

logs=(logs/*${^$(qstat)}(N))
(($#logs)) && tail -F $logs

Yes, doing filename expansion upon command substitution and other expansions is generally not wanted¹ and not done by default in zsh except in sh/ksh emulation (globsubst option).

While you could use ${~$(...)} to request the use of globsusbt for that particular command substitution, a much better way to do it with zsh would be:

ids=($(qstat))
tail -F logs/*${^ids}

Note that if any of those globs fail to match any file, the command will be aborted.

tail -F logs/*${^ids}(N)

would avoid that but would run tail -F without argument if there was no file at all.

You could also make it:

logs=(logs/*${^$(qstat)}(N))
(($#logs)) && tail -F $logs

¹ The fact that bash and other Bourne-like shells do it could be seen as a bug. That's one reason why you need to quote all your variables there, or why you need set -o noglob before running using an unquoted $(...) when you only want the splitting part of that split+glob. All more modern shells that don't carry the Bourne shell baggage like rc, es or fish don't do it either.

Source Link
Stéphane Chazelas
  • 584.9k
  • 96
  • 1.1k
  • 1.7k
Loading