function applyArguments(patterns, args) {
    const defaults = Object.create(null)

    return patterns.map(pattern => pattern.replace(ARGS_PATTERN, (whole, indirectionMark, id, options) => {
        if (indirectionMark != null) {
            throw Error(`Invalid Placeholder: ${whole}`)
        }
        if (id === "@") {
            return shellQuote.quote(args)
        }
        if (id === "*") {
            return shellQuote.quote([args.join(" ")])
        }

        const position = parseInt(id, 10)
        if (position >= 1 && position <= args.length) {
            return shellQuote.quote([args[position - 1]])
        }

        // Address default values
        if (options != null) {
            const prefix = options.slice(0, 2)

            if (prefix === ":=") {
                defaults[id] = shellQuote.quote([options.slice(2)])
                return defaults[id]
            }
            if (prefix === ":-") {
                return shellQuote.quote([options.slice(2)])
            }

            throw Error(`Invalid Placeholder: ${whole}`)
        }
        if (defaults[id] != null) {
            return defaults[id]
        }

        return ""
    }))
}
Replaces argument placeholders (such as `{1}`) by arguments.

@param {string[]} patterns - Patterns to replace.
@param {string[]} args - Arguments to replace.
@returns {string[]} replaced