• Intro Headers Instructions Macros Commands
Fork me on GitHub
    • Getting Started
      • Introduction
      • How to install bnd
      • Guided Tour Workspace & Projects
      • bnd / bndlib Features and JAR Wrapping Techniques
      • FAQ - Frequently Asked Questions
    • Concepts and Practices
      • Concepts
      • Background
      • Best practices
    • Build and Development
      • Build
      • Generating JARs
      • Versioning
      • Baselining
      • Service Components
      • Metatype
      • Contracts
      • Bundle Annotations
      • Accessor Properties
      • SPI Annotations
    • Dependency and Launching
      • Resolving Dependencies
      • Launching
      • Startlevels
    • Testing
      • Testing
      • Testing with Launchpad
    • Packaging and Distribution
      • Packaging Applications
      • JPMS Libraries
      • Wrapping Libraries to OSGi Bundles
    • Documentation and Tools
      • Generating Documentation
      • bnd CLI Commands
      • For Developers
      • Templates for Workspaces
      • Tips for Windows users
      • Tools bound to bnd
    • Reference Material
      • Reference
      • Headers
      • Instruction Reference
      • Instruction Index
      • Macro Reference
      • Macro Index
      • Plugins
      • External Plugins
    • Configuration and Troubleshooting
      • Settings
      • Errors
      • Warnings
  • separator

    Prev Next
    Macro
    Get the operating system's file separator character

    Summary

    The separator macro returns the operating system’s file separator character used in file paths.

    Syntax

    ${separator}
    

    Parameters

    None - this macro takes no parameters.

    Behavior

    • Returns / (forward slash) on Unix/Linux/Mac systems
    • Returns \ (backslash) on Windows systems
    • Returns the value of File.separator in Java

    Examples

    Get the file separator:

    ${separator}
    # Returns: "/" on Unix, "\" on Windows
    

    Build paths manually:

    path=${basedir}${separator}src${separator}main${separator}java
    

    Use in conditionals:

    ${if;${equals;${separator};/};unix;windows}
    

    Replace separators:

    ${replacestring;${path};${separator};/}
    

    Use Cases

    • Determining the platform at build time
    • Manual path construction
    • Path manipulation and normalization
    • Platform-specific logic
    • Cross-platform path handling

    Notes

    • Returns a single character: / or \
    • This is the file/directory separator, not the path separator
    • Path separator (for classpath) is different - see ${pathseparator}
    • See also: ${osfile} for OS-specific path creation
    • See also: ${pathseparator} for path list separator (: or ;)

    See test cases in MacroTestsForDocsExamples.java

Prev Next
Search
    • Home