How to overload / customize bash (or any other shell) commands handler?

When in bash some non existing command is run, corresponding error message appears:

$ non-existent-command
non-existent-command: command not found

Is it possible to customize this behavior?

I would like to achieve the following. When the entered command matches, for example, the pattern sddd, it should be handled specially:

  • s should be extracted and used as a command,
  • ddd should be extracted and used as an argument for the s command.
  • The command created by parsing the above should be run.

This can normally be achieved by means of a function named s that takes the needed arguments. A normal call is used to run such a function. For example:

s 123

But I want to customize the behavior of bash to be able to run such a function with, for example, the following calls:

  • s123
  • s500

I tried to find related information in man bash by the following keywords: overload, custom, override and did not succeed.

As I understand it, I need to somehow customize the bash handler that is used for processing input. I did not investigate bash source code to understand if this is feasible.

It will be best to come up with solution that is usable for any shell.

Probably creating a custom bash wrapper/adapter with the needed logic and using it instead of standard bash binary will solve this.