Skip to content

[BASH] _SHUNIT_LINENO_ error if IFS is redefined #167

Open
@Maxouwell

Description

@Maxouwell

The ${_SHUNIT_LINENO_} call at the start of assert* functions fails if IFS is redefined

#!/usr/bin/env bash

function test_SHUNIT_LINENO_bug() {
  local var=1

  PREVIOUS_FIELD_SEPARATOR=$IFS
  IFS=,
  assertEquals "$var" "$var" >&2
  IFS=$PREVIOUS_FIELD_SEPARATOR
}

source shunit2

result in

test_SHUNIT_LINENO_bug
shunit2: line 176: eval __shunit_lineno=""; if ${__SHUNIT_BUILTIN} [ "${1:-}" = "--lineno" ] && ${__SHUNIT_BUILTIN} [ -n "${2:-}" ]; then __shunit_lineno="[${2}]"; shift 2; fi;: command not found

Ran 1 test.

OK

Bash version (On Ubuntu in WSL2)

bash --version
GNU bash, version 5.0.17(1)-release (x86_64-pc-linux-gnu)                    
Copyright (C) 2019 Free Software Foundation, Inc.                            
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
                                                                             
This is free software; you are free to change and redistribute it.           
There is NO WARRANTY, to the extent permitted by law.                 

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions