mirror of
				https://github.com/facebook/zstd.git
				synced 2025-10-31 00:04:03 -04:00 
			
		
		
		
	
		
			
				
	
	
		
			29 lines
		
	
	
		
			655 B
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			29 lines
		
	
	
		
			655 B
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
| #!/bin/sh
 | |
| set -e
 | |
| 
 | |
| # Constants
 | |
| INCLUDE='include/'
 | |
| LIB='lib/'
 | |
| SPACES='    '
 | |
| TAB=$'\t'
 | |
| TMP="replacements.tmp"
 | |
| 
 | |
| echo "Files: " $INCLUDE* $LIB*
 | |
| 
 | |
| # Check files for existing tabs
 | |
| grep "$TAB" $INCLUDE* $LIB* && exit 1 || true
 | |
| # Replace the first tab on every line
 | |
| sed -i '' "s/^$SPACES/$TAB/" $INCLUDE* $LIB*
 | |
| 
 | |
| # Execute once and then execute as long as replacements are happening
 | |
| more_work="yes"
 | |
| while [ ! -z "$more_work" ]
 | |
| do
 | |
|   rm -f $TMP
 | |
|   # Replaces $SPACES that directly follow a $TAB with a $TAB.
 | |
|   # $TMP will be non-empty if any replacements took place.
 | |
|   sed -i '' "s/$TAB$SPACES/$TAB$TAB/w $TMP" $INCLUDE* $LIB*
 | |
|   more_work=$(cat "$TMP")
 | |
| done
 | |
| rm -f $TMP
 |