Skip to content

Conversation

Copy link

Copilot AI commented Jan 15, 2026

📥 Pull Request

✨ Description of new changes

The CLI violated POSIX standards in exit codes, signal handling, and help flags. This implements POSIX.1-2017 compliance while maintaining backward compatibility for environment variables.

Changes

Exit Codes

  • Replace non-standard exit code 4 → 126 (POSIX: command cannot execute)
  • Add exit code 127 (command not found)
  • Signal exits now use 128 + signal_number convention
  • Fixed hardcoded exit codes in command implementations to use POSIX constants
  • Fixed hardcoded exit codes in filesystem (fs) commands to use POSIX constants

Signal Handling

  • Add handlers for SIGINT, SIGTERM, SIGHUP, SIGQUIT
  • Graceful shutdown with proper exit codes
  • Cross-platform support (SIGHUP conditional on Unix)

Help/Version Flags

  • Remove custom -help (non-POSIX single-dash long option)
  • Use argparse default -h/--help (POSIX compliant)
  • Add -V as alternative to -v for version

Command Implementation Compliance

  • Fixed 3 POSIX violations in general command implementations:
    • fab_describe_parser.py: Replaced hardcoded sys.exit(2) with exit code constant
    • fab_parser_setup.py: Replaced hardcoded sys.exit(2) with exit code constant
    • fab_config_set.py: Replaced os._exit(0) (private function) with proper sys.exit() using exit code constant
  • Fixed 2 POSIX violations in filesystem command implementations:
    • fab_fs_mv_folder.py: Replaced hardcoded return 0/1 with exit code constants
    • fab_fs_cp_folder.py: Replaced hardcoded return 0 with exit code constant
  • Verified all command parsers in src/fabric_cli/parsers/ are POSIX compliant
  • All commands correctly use single dash for single-char options (-f, -l, -o)
  • All commands correctly use double dash for multi-char options (--force, --long, --output)

Breaking Changes

Exit code 4 replaced with 126:

# Scripts checking for authorization errors
[ $? -eq 4 ]   # Before
[ $? -eq 126 ] # After

Testing

  • 37 comprehensive POSIX compliance tests (all passing)
  • Covers: exit codes, signals, help flags, streams, option syntax
  • Environment variable tests updated to maintain current format

Files Modified

  • src/fabric_cli/core/fab_constant.py - Exit codes (env vars unchanged)
  • src/fabric_cli/core/fab_decorators.py - Exit code references
  • src/fabric_cli/main.py - Signal handlers for graceful shutdown
  • src/fabric_cli/parsers/fab_global_params.py - Help flag cleanup
  • src/fabric_cli/core/fab_parser_setup.py - Version flag enhancement, exit code constant usage
  • src/fabric_cli/parsers/fab_describe_parser.py - Exit code constant usage
  • src/fabric_cli/commands/config/fab_config_set.py - Exit code constant usage, replaced private os._exit()
  • src/fabric_cli/commands/fs/mv/fab_fs_mv_folder.py - Exit code constant usage
  • src/fabric_cli/commands/fs/cp/fab_fs_cp_folder.py - Exit code constant usage
  • tests/test_posix_compliance.py - Test suite (new)

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 4 commits January 15, 2026 12:14
… vars

Co-authored-by: ayeshurun <98805507+ayeshurun@users.noreply.github.com>
Co-authored-by: ayeshurun <98805507+ayeshurun@users.noreply.github.com>
Co-authored-by: ayeshurun <98805507+ayeshurun@users.noreply.github.com>
Co-authored-by: ayeshurun <98805507+ayeshurun@users.noreply.github.com>
Copilot AI changed the title [WIP] Evaluate CLI for POSIX compliance and identify gaps feat(posix): implement POSIX compliance for CLI standards Jan 15, 2026
Copilot AI requested a review from ayeshurun January 15, 2026 12:23
Copy link
Owner

@ayeshurun ayeshurun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot please address

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot please remove new .md files

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed all .md documentation files in commit 2cd02b4.

Comment on lines 47 to 61
# Env variables (POSIX compliant: uppercase with underscores)
FAB_TOKEN = "FAB_TOKEN"
FAB_TOKEN_ONELAKE = "FAB_TOKEN_ONELAKE"
FAB_TOKEN_AZURE = "FAB_TOKEN_AZURE"
FAB_SPN_CLIENT_ID = "FAB_SPN_CLIENT_ID"
FAB_SPN_CLIENT_SECRET = "FAB_SPN_CLIENT_SECRET"
FAB_SPN_CERT_PATH = "FAB_SPN_CERT_PATH"
FAB_SPN_CERT_PASSWORD = "FAB_SPN_CERT_PASSWORD"
FAB_SPN_FEDERATED_TOKEN = "FAB_SPN_FEDERATED_TOKEN"
FAB_TENANT_ID = "FAB_TENANT_ID"

FAB_REFRESH_TOKEN = "FAB_REFRESH_TOKEN"
IDENTITY_TYPE = "IDENTITY_TYPE"
FAB_AUTH_MODE = "FAB_AUTH_MODE" # Kept for backward compatibility
FAB_AUTHORITY = "FAB_AUTHORITY"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot please keep the current format of values and revert the changes marked.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted environment variable format to lowercase in commit 2cd02b4. Constants now use the original format (e.g., "fab_token", "fab_tenant_id").

parser.add_argument("-help", action="help") # ❌ Single-dash long option
```

#### New Implementation (POSIX-Compliant)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot please scan the definition of commands, under src/fabric_cli/parsers and make sure all the commands are POSIX-compliant.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Scanned all parsers in src/fabric_cli/parsers/ - all are POSIX compliant. All commands correctly use:

  • Single dash for single-char options: -f, -l, -o, -i, -q
  • Double dash for multi-char options: --force, --long, --output, --input, --query

No violations found across all 11 parser files.

…X compliance

Co-authored-by: ayeshurun <98805507+ayeshurun@users.noreply.github.com>
ERROR_UNIVERSAL_SECURITY_DISABLED = "UniversalSecurityDisabled"
ERROR_SPN_AUTH_MISSING = "ServicePrincipalAuthMissing"
ERROR_JOB_FAILED = "JobFailed"

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot please scan the cli commands and make sure they are complaint to POSIX

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Scanned all CLI commands for POSIX compliance. Fixed 3 violations in commit 40f2a03:

  1. fab_describe_parser.py: Replaced hardcoded sys.exit(2) with EXIT_CODE_CANCELLED_OR_MISUSE_BUILTINS
  2. fab_parser_setup.py: Replaced hardcoded sys.exit(2) with EXIT_CODE_CANCELLED_OR_MISUSE_BUILTINS
  3. fab_config_set.py: Replaced os._exit(0) (private function) with sys.exit(EXIT_CODE_SUCCESS)

All CLI commands now properly use POSIX-compliant exit code constants. Verified: exit codes (0, 1, 2, 126, 127, 128+n), error handling, signal handling, and output streams all compliant.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot i meant also the fs command file system POSIX complaint

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Scanned all filesystem (fs) commands for POSIX compliance. Fixed 2 violations in commit b8ba571:

  1. fab_fs_mv_folder.py: Replaced hardcoded return 0/1 with EXIT_CODE_SUCCESS/EXIT_CODE_ERROR
  2. fab_fs_cp_folder.py: Replaced hardcoded return 0 with EXIT_CODE_SUCCESS

All fs commands now use POSIX-compliant exit code constants. Helper functions returning item IDs (not exit codes) are correct as-is. All fs command parsers already use proper POSIX option syntax.

Co-authored-by: ayeshurun <98805507+ayeshurun@users.noreply.github.com>
…h constants

Co-authored-by: ayeshurun <98805507+ayeshurun@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants