I want to implement a userland command that will take one of its arguments (path) and change the directory to that dir. After the program completion I would like the shell t
That is not going to be possible.
Your script runs in a sub-shell spawned by the parent shell where the command was issued.
Any cding done in the sub-shell does not affect the parent shell.
cd