Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

13
LINES

< > BotCompany Repo | #1000832 // bashQuote function

JavaX fragment (include)

/** possibly improvable */
static String bashQuote(String text) {
  if (text == null) return null;
  return "\"" + text
    .replace("\\", "\\\\")
    .replace("\"", "\\\"")
    .replace("\n", "\\n")
    .replace("\r", "\\r") + "\"";
}

static String bashQuote(File f) {
  ret bashQuote(f.getAbsolutePath());
}

Author comment

Began life as a copy of #1000830

download  show line numbers  debug dex  old transpilations   

Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, sawdedvomwva, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1000832
Snippet name: bashQuote function
Eternal ID of this version: #1000832/1
Text MD5: 9ca83e09420eded8bc9329be28c31872
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-08-07 17:39:01
Source code size: 322 bytes / 13 lines
Pitched / IR pitched: No / No
Views / Downloads: 883 / 3143
Referenced in: #1002427 - Accellerating 629 (SPIKE)
#1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1020284 - bashQuote2 - don't use quotes, just use backslashes (dev.)
#1032383 - safeBashQuote function - single quotes
#3000382 - Answer for ferdie (>> t = 1, f = 0)