Skip to main content

valid_refname

Function valid_refname 

Source
pub fn valid_refname(val: &str, flags: i32) -> bool
Expand description

Port of valid_refname(char *val, int flags) from Src/params.c:6466. C body validates a nameref target name. Two paths:

  • PM_UPPER (typeset -nu): reject digit-leader (positional refs would loop) and the literal argv/ARGC names.
  • non-PM_UPPER: positional digit-leader is permitted (must be all-digits before any [); otherwise scan via itype_end(INAMESPC). Either path then accepts the trailing one-char specials ! ? $ - _ and an optional [subscript] tail. Returns 1 on valid, 0 otherwise. The Rust port follows the same control flow with is_ascii_digit/is_alphabetic standing in for idigit/itype_end.