Answer the question
In order to leave comments, you need to log in
What is the data type of [email protected] in BASH?
Slowly I encounter various subtleties of BASH and have reached a dead end. I just can't figure out a simple thing - what is the data type of [email protected] and ${somearray[@]}? More precisely, not even so, the first question is: is it true that [email protected] is completely similar in behavior and usage to ${somearray[@]}? (where somearray is some array).
And the second question, in fact - what data type does [email protected] have and, most importantly, where can I read comprehensive information on how to work with this data type and what does its use in different situations lead to?
Let me explain: there are tricks like ${@: -1}. If [email protected] were a string, then such a construction would return the last character. And it returns the last element of the array, in the case of [email protected] - the last element of a generally non-existent array of all input arguments.
Please clarify what kind of animal this is, how to work with it, and most importantly - what opportunities does it have?
As I understand it, [email protected] is some intermediate pseudo-type, something between an array and a string, which cannot be obtained by external means. [email protected] almost always pretends to be a string of space-separated components, and the only unique property I've found of it is ${@: N} - cutting off the first or last N components. Nothing more intelligible could be dug up / thought up. I really appreciate the help, I would like to understand.
Answer the question
In order to leave comments, you need to log in
In general, it is rather an untyped array, the value type of any member of which depends on the interpretation. In general, all arrays in bash can be considered untyped.
#!/bin/bash
echo [email protected]
array=()
[email protected]
echo ${array[@]}
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question