$# is a special variable in bash, that expands to the number of arguments
a.sh
Code:
#!/usr/bin/bash
echo "$#"
Code:
bash -c 'echo $#'
0
bash -c 'echo $#' - A
1
bash -c 'echo $#' - A B
2
bash ./a.sh foo bar
2
Now, to the problem I see.
If ctx is zero length then ctx = 8
Code:
[[ -z "$ctx" ]] && ctx=8
echo "$ctx"
8
ictx=( -C "$ctx" )
echo "$ictx"
-C
ictx="-C "$ctx""
echo "$ictx"
-C 8
You also try and set the same variable 3 times
Code:
ictx=( -C "$ctx" )
ictx=( -A "$afctx" )
ictx=( -B "$bfctx" )
Code:
a=1
a=2
a=3
echo "$a"
3
All that I can tell you without seeing more.