#!/usr/bin/env bash # $Id: mdd,v 1.1 2019/05/29 19:37:29 friedman Exp $ # Wrapper around `dd' to join args with `=' where required. # This makes it easier to do filename completion on args without changing # the syntax of `=' in emacs, since that is a valid file name character. dd_op=( if ibs iflag bs cbs conv of obs oflag seek skip count status ) apush() { eval "$1=(\"\${$1[@]}\" \"\${@:2}\")"; } member() { eval set : "$1" "\"\${$2[@]}\"" shift while [ $# -gt 1 ]; do case $2 in $1 ) return 0 ;; esac set : "$1" "${@:3}" shift done return 1 } main() { declare -a ddarg=() while [ $# -gt 0 ]; do if member "$1" dd_op; then apush ddarg "$1=$2" shift else apush ddarg "$1" fi shift done exec ${DD-dd} "${ddarg[@]}" } main "$@" # eof