Skip to content

Commit

Permalink
Update lib/completion.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmurdoch committed Feb 13, 2024
1 parent 7866f56 commit eabf219
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions lib/completion.ts
Expand Up @@ -350,13 +350,8 @@ export class Completion implements CompletionInstance {
? templates.completionZshTemplate
: templates.completionShTemplate;
let name = this.shim.path.basename($0);
// Santize `name` to make sure it is a valid bash function name
// first, check if the first character is an alphabetic character or underscore
if (!str.match(/^[A-Za-z_]/)) {
// If not, prepend name with an underscore
name = '_' + name;
}
// Then, replace any characters that are not alphanumeric or underscore with an underscore
// Santize `name` to make sure it is a valid bash function name by
// replacing any characters that are not alphanumeric or underscore with an underscore
name = name.replace(/[^A-Za-z0-9_]/g, '_');

// add ./ to applications not yet installed as bin.
Expand Down

0 comments on commit eabf219

Please sign in to comment.