Before this lesson, complete bash-conditionals.
This course runs GNU Bash with ordinary GNU text tools in a fresh Linux sandbox.
An indexed Bash array stores a separate string at each occupied integer index. For the dense arrays in this lesson, start with items=() and append with items+=("$value"). The quotes belong inside the parentheses: they preserve one new element even when the value is empty. Unquoted insertion can change the number and content of elements before the array ever stores them.
Apply the contract
Iterate with for item in "${items[@]}". Use ${#items[@]} for the count of assigned elements, not the length of one string. Indexed arrays can be sparse, so this count is not generally the highest index plus one. The lab deliberately constructs a dense result by appending. Sorting would simplify uniqueness but would violate the requirement to preserve encounter order.
items=('alpha beta' '' '*')
items+=('tail')
printf 'elements=%s\n' "${#items[@]}"
for item in "${items[@]}"; do printf '<%s>\n' "$item"; doneReason about the edge cases
For a small input, compare each new argument with every retained value. Append only after the scan finds no exact match. In [[ $existing == "$value" ]], quoting the right-hand expansion makes it literal. An unquoted right-hand side is a pattern: a star would match any existing string. Empty strings deserve explicit tests because they are valid elements, and a truthiness-style check would discard them. This nested scan is quadratic in the number of values, which is acceptable for the stated small inputs; the important property is an exact, ordered result.
Practice
Print the first occurrence of each distinct positional argument, preserving order and exact contents. First print count=N, then <VALUE> per retained argument. Empty strings and pattern characters are valid values. Inputs are small; a simple nested scan is sufficient. Do not sort the result.
Run sample starts again from the first public fixture and grants no mastery evidence. Submit checks all fixtures, including edge cases. Read the specification before editing; the bug and fill phases share the build’s contract. Flashcards reinforce recall on a separate schedule.