Help understand awk command

Help understand awk command
This command converts the column values to rows.

Command:

awk -s1=" " '{S=S?S OFS s1 $0 s1:s1 $0 s1} END{print S}' OFS=,  Input_file

Example:

1
2
3

is converted to:

1, 2, 3

Can anyone please help me understand this command?

I'm afraid it doesn't as it has a syntax error. Did you run it as given?
Upfront variable definition needs the -v option.

Not quite - there are spaces before the commas.

Once you corrected that, it uses a "conditional assignment" to check the S variable and, if non-null, adds the actual input line ( $0 ) enclosed in spaces to it, else assigns it just the latter.

This does similar thigs making use of awk 's default bebaviour:

awk '$1=$1' RS= OFS=, file
1,2,3