#!/bin/sh args() { local i=0 while [ -n "$1" ]; do i=$((${i} + 1)) echo "ARG ${i}: $1" shift done } var="--exec-on-eostudy '/usr/bin/dcm_write_dir #p #f #a #c'" args one two three args one 'two three' args ${var} args "${var}" eval args "${var}"