Artificial intelligent assistant

Filter out command line options before passing to a program I am running `cmake` and it is passing a flag to my linker that is unrecognized (`-rdynamic`), and it's causing an error. I cannot figure out where it is getting this flag from, so I want to just filter it out. I can specify `-DCMAKE_LINKER=<linker>`, so what I would like to do is set `<linker>` to a program that reads its command line arguments, filters out the bad one, and then passes the result back to the actual linker. I have been using `awk '{gsub("-rdynamic", "");print}'`, but I don't know to make the input stdin and the output ld.

This `bash` script loops through its arguments, ignoring those matching the string "`-rdynamic`", and adding any others to an array. Once it runs out of arguments, it executes `ld` with the filtered list.


#!/bin/bash

declare -a finalopts
finalopts=()

for o in "$@"; do
if [ "$o" = "-rdynamic" ] ; then
continue
fi
#add all other options to the list
finalopts+=("$o")
done

exec ld "${finalopts[@]}"

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy fc3613ada44232db980ce85003183fff