Using fish version 2.7.1-1113-ge598cb23 (3.0 pre-alpha) you can use set -a
(append) or set -p
(prepend).
set -l array "tiny tim" bob
set -l children joe elias matt
echo $children
for i in (seq 2)
set -a children $array[$i]
end
echo $children
Output:
joe elias matt
joe elias matt tiny tim bob
You could also use the string command which should work on most recent versions of fish.
set -l array "tiny tim" bob
set -l children joe elias matt
echo $children
for i in (seq 2)
set children (string join " " $children $array[$i])
end
echo $children
Output:
joe elias matt
joe elias matt tiny tim bob
echo $children
will show lists as space-separated, so try something likestring escape -- $children
instead.printf '|%s|\n' $children
or, if you're using a new enough versionset --show children
.echo $children | tr ' ' \n