Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

wierd if statement #139

@oceanMIH

Description

@oceanMIH

hi guys, would someone please explain the follow:

  • in the terminal, the following code is NOT OK:
if  ;then echo yes;fi
-bash: syntax error near unexpected token `;'
  • but if i run it in a shell file, the code is OK, why?
cat tmp.sh
if  $1 ;then echo yes;fi

./tmp.sh
yes

I test these on bash version: 5.0.0(1)-release, 4.4.20(1)-release

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions